Increase width of seach textbox inside navbar-header - html

I have a search textbox in navbar-header, on collapse, the width of the textbox is fine. But in full screen, the textbox width is reduced. How can I increase the width in full screen mode?
I know there are a lot of questions, like this on SO and the web.
However, I have tried all the suggestions, none has helped me.
here is my code, can someone tell what I'm doing wrong?
Thanks.
.navbar .navbar-form {
padding: 0 15px;
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.navbar-inverse {
background: #465f62;
border: none;
}
.navbar-inverse .navbar-brand {
color: white;
font-size: 40px;
}
.navbar-inverse .navbar-nav > li > a {
color: white;
font-size: 18px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#navbar-collapse-area">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Colony</a>
<div class="col-sm-6 col-md-6 col-lg-8">
<form class="navbar-form" role="search">
<div class="form-group" style="display:inline;">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term">
<span class="input-group-btn">
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</span>
</div>
</div>
</form>
</div>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse-area">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
Hello Doe <span class="caret"></span>
<ul class="dropdown-menu pull-right">
<li class="dropdown">Log Out
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>

JSBIN
Because bootstrap(BT) just use the default input width to achieve the navbar input. So if you want to redefine the width of input, maybe jquery is a better choice.
$(window).resize(function (){
var width = $(window).width();
$('input').width(width - 380);
})
the number 380 is from of the colony and Hello Doe width. After all, there is enough space to arrangement all elements.

Related

Move static positioned element left by arbitrary amount of pixels

I'm using a Bootstrap 4 navbar and added a left-border of a different color for design purposes.
This has the unforunate side-effect of causing the container of the navbar to not be lined up with the container of the main content.
I'm trying to offset the inner container 80px to compensate for the border, but when I try adjusting the position it obviously messes up the rest of the layout.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<style>
.navbar {
border-left: 80px solid red;
}
.navbar .container {
left: 80px; /* something like this */
}
</style>
</head>
<body>
<div class="content-wrapper">
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand"
href="/">Site</a>
<button class="navbar-toggler collapsed"
type="button"
data-toggle="collapse"
data-target="#mainMenu"
aria-controls="navbarsExampleDefault"
aria-expanded="false"
aria-label="Toggle navigation">
<span class="icon-bar top-bar"></span>
<span class="icon-bar middle-bar"></span>
<span class="icon-bar bottom-bar"></span>
</button>
<div class="collapse navbar-collapse"
id="mainMenu">
<div class="form-inline ml-auto">
<label class="sr-only"
for="search-text">Search</label>
<div class="input-group mr-2 mb-2 mb-sm-0">
<input type="text"
class="form-control"
id="search-text"
placeholder="search...">
<div class="input-group-append">
<a href="/search/"
type="button"
id="search-button"
class="btn btn-light">
<i class="fas fa-search"></i>
</a>
</div>
</div>
<a href="/account/login"
class="btn btn-outline-light">log in</a>
<a href="/account/signup"
class="btn btn-info ml-2">sign up</a>
</div>
</div>
</div>
</nav>
<div class="container">
<ol class="breadcrumb my-4">
<li class="breadcrumb-item active">Bread crumbs</li>
</ol>
<h1>and some content</h1>
</div>
</body>
</html>
CodePen
You can add padding-right: 80px; to .navbar to push it back.
Not sure if I understood correctly but you can try:
.navbar {
border-left: 80px solid red;
}
.navbar .container {
left: 80px; /* something like this */
margin-left:0px !important
}

Change the position of a button to up

I have a header with a logo a dropdown menu and a search bar the problem is that dropdown button it's down and I want it to up.
I have this way:
But I want something like this where button is align with the logo and search bar:
I have tried a lot of things like call the class of button in css and put margin-button with a lot of pxls but its work, any suggestion?
This is my code HTMl where I have the button:
<header>
<nav class="navbar navbar-default navbar-custom" role="navigation">
<div class="container">
<a class="navbar-left" href="#"><img src="assets/img/logo-01.png" style="max-width:70px"/></a>
<div class="navbar-header navbar-left">
<button type ="button" class="navbar-toggle" data-toggle="collapse" data-target="#collapse-1">
<span class="sr-only"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="collapse navbar-collapse js-navbar-collapse">
<ul class="nav navbar-nav">
<div class="cd-dropdown-wrapper">
<button type="button" data-toggle="dropdown" class="btn btn-default dropdown-toggle cd-dropdown-trigger">Categorias</button>
<nav class="cd-dropdown">
Close
<ul class="cd-dropdown-content">
<li class="has-children">
Eletrodomésticos
<ul class="cd-secondary-dropdown is-hidden">
<li class="go-back">Menu</li>
<li class="see-all">Todos os eletrodomésticos</li>
<li class="has-children">
Eletrodomésticos
<ul class="is-hidden">
<li class="go-back">Eletrodomésticos</li>
<li class="see-all">Todos os eletrodomésticos</li>
<!--<li class="has-children">-->
<li>Grandes Eletro de cozinha</li>
....<!--(has other categories but it doesnt matter for here so I skip that part)-->
<form class="navbar-form navbar-left">
<div class="form-group">
<input type="text" class="form-control" placeholder="Pesquisar Produto">
</div>
<button type="submit" class="btn btn-danger">
<i class="glyphicon glyphicon-search"></i>
</button>
</form>
</div>
</div>
</div>
</nav>
</header>
This is my css code:
.btn-default {
margin-bottom: 350px;
background: #25727D;
border-color: #25727D;
position: absolute;
margin-left: 50px;
}
.btn-default {
margin-bottom:350px;
background: #25727D;
border-color: #25727D;
position:absolute;
margin-left:50px;
}
Since .btn-default already have position:absolute, just change top:10px or top:desiredValue accordingly to change vertical position of button.

Bootstrap moving logo

please I need advice. I am trying to move my logo in nav more to the right as I did with search form .navbar-right there is margin-right 150px, and I tried it also with .navbar-right included my logo and margin-left just don't work. When I have no div class navbar-right and trying to margin-left, it moves my nav to left also.
Would you be so kind and help me with this solution.
/* nav */
.navbar-right {
margin-right: 150px;
}
.navbar-left {
margin-left: 150px;
}
.nav {
margin-left: 500px;
position: static;
}
.navbar-brand {
margin-left: 150px;
}
.navbar-logo {
max-width: 200px;
max-height: 75px;
margin-top: 14px;
}
.form-control {
border-radius: 0px !important;
}
.btn {
border-radius: 0px !important;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="navbar-left">
<img class="navbar-logo" src="img/logo.png">
</div>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active">Home <span class="sr-only">(current)</span></li>
<li>About me</li>
<li>Portfolio</li>
<li>Services</li>
<li>Blog</li>
</ul>
<form class="navbar-form navbar-right">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search website">
</div>
<button type="submit" class="btn btn-default">Search</button>
</form>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
You can change margin-left: 150px; in .navbar-left to your desired amount.
just use .navbar-left {padding:12px;}
You can increase padding-left on your logo element. Or you can make it on your navbar-left div

PreNav (Bootstrap3) won't drop down in mobile view

I can't figure out exactly why my preNav won't drop down in mobile view. I think it might have something to do with the bootstrap.css, but I was hoping someone had some more insight on the issue. I currently have 2 'navbar navbar-fixed-top' horizontal navs on the top of my page. In mobile view, it looks like this:
and the 2nd nav (in white) drops down just fine, but clicking the top nav drop down (in black) has no reaction. Is this due to bootstrap.css? Any ideas would be helpful.Here is my CSS for each nav if it helps:
#nav1 {
position: relative;
top:0;
}
#nav2 {
position: relative;
border-bottom:none;
}
and HTML for topNav (Nav1):
<div class="container-full">
<div class="row">
<div class="navbar navbar-inverse navbar-fixed-top" id="nav1" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="col-sm-3 col-sm-3 pull-left">
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term">
<div class="input-group-btn">
<button class="btn btn-default" type="submit">GO</button>
</div>
</div>
</form>
</div>
<div class="collapse navbar-collapse navbar-collapse" id="pre-nav">
<ul class="nav navbar-nav" id="pre-nav-menu">
<li>Current Students</li>
<li>Staff</li>
<li>Employers</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<span id="phone">1.877.655.7676</span>
<input type="button" value="Request Info" class="btn btn-default pull-right" id="rinfoBtn" data-toggle="collapse" data-target=".navbar-collapse"/>
</ul>
</div>
</div>
It was indeed my data-target as vanburen pointed out. Instead of data-target=".navbar-ex1-collapse" I needed data-target=".navbar-collapse" , removing the 'ex1-' which must have been left in there as "example 1" from the original megaMenu source I pulled. Thanks vanburen!

Center twitter bootstrap navigation items

I'm trying to center my navigation items, what do I need to edit in order to do so? I've looked in the bootstrap.css file and can't find where to change the settings. I can't figure out how to do it I've been trying everything.
<div id="nav" class="navbar navbar-inverse navbar-static-top">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<ul class="nav">
<li class="active">Home</li>
<li>Forum</li>
<li>Download</li>
<li>Play Now</li>
<li>Register</li>
<li class="dropdown">
<a class="dropdown-toggle" id="dLabel" role="button" data-toggle="dropdown" data-target="#" href="/page.html">
Login
<b class="caret"></b>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<!-- login form -->
<form action="http://www.07-pk.com/forum/login.php" method="post" onsubmit="md5hash(vb_login_password,vb_login_md5password,vb_login_md5password_utf)">
<script type="text/javascript" src="http://www.07-pk.com/forum/clientscript/vbulletin_md5.js"></script>
Username: <input type="text" class="button" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="1" value="Username" onfocus="if (this.value == 'Username') this.value = '';" />
<br />
Password: <input type="password" class="button" name="vb_login_password" size="10" accesskey="p" tabindex="2" />
<input type="submit" class="button" value="Login" tabindex="4" title="" accesskey="s" />
<input type="hidden" name="s" value="" />
<input type="hidden" name="do" value="login" />
<input type="hidden" name="forceredirect" value="1" />
<input type="hidden" name="vb_login_md5password" />
<input type="hidden" name="vb_login_md5password_utf" />
<input type="hidden" name="url" value="http://www.07-pk.com" />
</form>
<!-- / login form -->
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
Twitter Bootstrap navigation items are having float: left by default. Consider adding the following styles to your own CSS file (or modify the bootstrap.css, which I would not recommend):
.navbar .nav li {
width: 100px; /* or whatever width you want for items */
display: inline-block;
float: none;
}
.navbar .nav {
float: none;
text-align: center;
}
Fiddle example
Wrap your objects you want to center with this <div>
<div style="width:300px; margin: 0 auto;">
//your code here
</div>
Brandon Himpfen give an example of this on his blog. http://www.himpfen.com/center-align-bootstrap-nav-pills/ "In Twitter Bootstrap there are navigation (nav) pills and by default, it is left aligned. We can wrap the navigation with a HTML div element and add a bit of CSS."
http://www.bootply.com/AiyCfTCcBV
/* CSS used here will be applied after bootstrap.css */
.centered-pills {
text-align: center;
}
.centered-pills ul.nav-pills {
display: inline-block;
}
.centered-pills li {
display: inline;
}
.centered-pills a {
float: left;
}
* html .centered-pills ul.nav-pills, *+html .centered-pills ul.nav-pills {
display: inline;
}
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<a class="navbar-brand pull-left" href="#">Brand</a>
<div class="centered-pills">
<ul class="nav nav-pills">
<li>Home</li>
<li>Profile</li>
<li>Messages</li>
</ul>
<a class="navbar-brand pull-right" href="#">Brand</a>
</div>
</div>
</nav>