Radio buttons in bootstrap navigation bar - css

I'm trying display some elements positioned in the center (like dropdown list) of nav bar. But my radio buttons doesn't want to get offset. What should I add to my code?
<nav class="navbar navbar-default navbar-fixed-top second-navbar" role="navigation">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li class="container">
<form role="form">
<label class="radio-inline"><input type="radio" name="gr" value="0" onchange="val(this)">Popular first</label>
<label class="radio-inline"><input type="radio" name="gr" value="1" onchange="val(this)">Newest first</label>
</form>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" role="button">
Items per page: <b>#Model.PagingInfo.ItemsPerPage</b>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>5</li>
<li>10</li>
<li>20</li>
</ul>
</li>
</ul>
</div>
</nav>

You need to add div with class radio. also you need to remove unnecessary tags
<nav class="navbar navbar-default navbar-fixed-top second-navbar" role="navigation">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li class="radio">
<label class="radio-inline">
<input type="radio" name="gr" value="0" onchange="val(this)">Popular first</label>
<label class="radio-inline">
<input type="radio" name="gr" value="1" onchange="val(this)">Newest first</label>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" role="button">
Items per page: <b>#Model.PagingInfo.ItemsPerPage</b>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>5</li>
<li>10</li>
<li>20</li>
</ul>
</li>
</ul>
</div>
Here is the codepen : http://codepen.io/anon/pen/MKqwgJ

There is slight change in your markup buddy. Just do these listed changes and it will be perfect as you wanted.
1.) remove the class container from your <ul> tag.
2.) To move the radio button to the left, add this bootstrap class to the radio button <li> tag.
<li class="navbar-left">
3.) To move the dropdown to the right, add this bootstrap class to the dropdown <li> tag.
<li class="dropdown navbar-right">
4.) Now for the top spacing, you need to give some padding to the radio button form just like the one dropdown list has.
form {
padding: 10px 15px;
}
Voila ... perfectly aligned ! Here is the JSFiddle

Related

Bootstrap button alignment with Navbar list menu?

I'm creating a small website and I'm stuck with the button alignment problem. I have a navbar list menu and I'd like to add a transparent Logout button near to them just in shape of another menu element, however, I couldn't be successful so far.
Here's a Bootply link you could see the problem; http://www.bootply.com/OXfRkJHEHs
I'd be grateful if you could help me.
<form>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="hidden">
</li>
<li>
<a style="color:#900C3F" href="index.php">Home</a>
</li>
<li>
<a style="color:#900C3F" href="festival.php">Festival</a>
</li>
<li>
<a style="color:#900C3F" href="contact.php">Contact</a>
</li>
<li>
<a style="color:#900C3F" href="map.php">Map</a>
</li>
<li>
<input type="submit" value="Logout" class="btn element" style="color:#900C3F; background-color: transparent; margin-top:7px" href="Logout.php">
</li>
</ul></div>
<div id="push"></div>
</form>

How to put 2 drop down menu and a search bar nect to each other using the CSS bootstrap

I am currently using the CSS bootstrap 3.2 in my application.
I am trying to place 2 drop down menu "with the arrow only- not button style" next to each other and then to the right I want to add a search bar.
I want to use the the dropdown menu that the bootstrap has but without the button style "arrow only" and a small search bar to the right in the vertical center.
I have tried to do that but the dropdown menus and the search bar do not line up.
here is a screenshot of what I have done
and here is my code
<ul class="nav nav-pills">
<li class="dropdown">
<a class="dropdown-toggle menu-sm-padding" data-toggle="dropdown" href="#">
My Name <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>My Profile</li>
<li role="presentation" class="divider"></li>
<li>Logout</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle menu-sm-padding" data-toggle="dropdown" href="#">
My Company Name <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu"><li><a class="master_client_change" href="#" id="current_client_id_2">Comp 1</a></li><li><a class="master_client_change" href="#" id="current_client_id_1">Comp 2</a></li><li><a class="master_client_change" href="#" id="current_client_id_3">Comp 3</a></li><li><a class="master_client_change" href="#" id="current_client_id_6">Comp 4</a></li></ul>
</li>
</ul>
<div class="width-sm-size box-inline-block">
<form action="/accounts_search.php" method="get" id="searchforactivities" class="navbar-form navbar-right row-right-xxsm-margin" role="search">
<div class="input-group">
<input type="search" class="form-control" name="search_term">
<span class="input-group-btn">
<button class="btn btn-default" type="submit">Go</button>
</span>
</div>
</form>
</div>
How can I get the dropdown menu and the search bar to line up?
and is there a trick in making the search bar little fancy by making the the corners of the input round and the Go button a search icon?

Twitter Bootstrap 3.0.3 Navbar Aligning Navbar Header

I'm having difficulty to centering my navbar brand logo.
currently, my logo will align far to the left.
what I want actually to align it center from the first link. Kindly find below for the sample :
Please find below my code at JSFiddle
http://jsfiddle.net/QSa8v/3/
<div id="navbar">
<nav role="navigation" class="navbar-custom">
<div class="navbar-header">
<button data-toggle="collapse" data-target="#ren-nav-collapse" class="navbar-toggle">
<span class="sr-only">
Toggle navigation
</span>
<span class="icon-bar" />
<span class="icon-bar" />
<span class="icon-bar" />
</button>
<a href="#" class="navbar-brand">
<img src="http://i.imgur.com/CMEnIo7.png" />
</a>
</div>
<div class="collapse navbar-collapse" id="ren-nav-collapse">
<ul class="nav navbar-nav">
<li>
LINK 1
</li>
<li>
LINK 2
</li>
<li>
LINK 3
</li>
<li>
LINK 4
</li>
<li>
LINK 5
</li>
<li>
LINK 6
</li>
</ul>
</div>
</nav>
</div>
Really need your kind answer.
Look at here : http://jsfiddle.net/QSa8v/4/
HTML changes :
<div id="navbar">
<nav role="navigation" class="navbar-custom">
<div class="navbar-header col-xs-3 myheader"> // CHANGE HERE
<button data-toggle="collapse" data-target="#ren-nav-collapse" class="navbar-toggle">
<span class="sr-only">
Toggle navigation
</span>
<span class="icon-bar" />
<span class="icon-bar" />
<span class="icon-bar" />
</button>
<a href="#" class="navbar-brand mybrand"> // CHANGE HERE
<img src="http://i.imgur.com/CMEnIo7.png" />
</a>
</div>
<div class="collapse navbar-collapse" id="ren-nav-collapse">
<ul class="nav navbar-nav mybar"> // CHANGE HERE
<li>
LINK 1
</li>
<li>
LINK 2
</li>
<li>
LINK 3
</li>
<li>
LINK 4
</li>
<li>
LINK 5
</li>
<li>
LINK 6
</li>
</ul>
</div>
</nav>
</div>
CSS added :
.mybar {
margin-left:0px !important;
}
.mybrand{
float:none !important;
}
.myheader{
text-align: center;
padding: 1em;
}

Opening dropdown menu from navbar branding

I would like to open a dropdown menu (using Twitter Bootstrap) everytime I click on the brand of my navbar, so I tried this code:
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="tabbable">
<div class="dropdown">
<a id="drop1" class="dropdown-toggle" data-toggle="dropdown" href="#menu">
<div class="brand">Brand</div>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="drop1">
<li>Action</li>
</ul>
</div>
<ul class="nav">
<li>
Item
</li>
</ul>
</div>
</div>
</div>
Result: when I click on it, the menu appears, but it's over the brand, not under. How to fix it?
Examples
Standard version [OK]: http://jsfiddle.net/4rdPU/2/
Standard version + div class="brand" [Style problem]: http://jsfiddle.net/4rdPU/1/
Brand version [Wrong menu position]: http://jsfiddle.net/4rdPU/3/
To properly render the dropdown, your brand must be a .nav li element. So just add the .brand class to a standard dropdown.
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="tabbable">
<ul class="nav">
<li class="dropdown">
<a id="drop1" class="dropdown-toggle brand" data-toggle="dropdown" href="#menu">
Brand
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="drop1">
<li>Action</li>
</ul>
</li>
<li>
Item
</li>
</ul>
</div>
</div>
</div>
That will break your brand positioning, but you fan fix it with this simple CSS:
.navbar .brand {
margin-left: 10px; /* This value could be different for another layout */
}

Responsive navbar in Bootstrap

I am currently using bootstrap with my website and am trying to take advantage of the responsive features, one of which is the navbar button on smaller screens/devices. Now I have made some changes to the navbar, one of which is centering it rather than the default float left and it looks like this:
<div class="navbar navbar-fixed-top center">
<div class="navbar-inner">
<div class="container-fluid">
<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="nav-collapse">
<ul class="nav">
<li class =active >Home</li>
<li class="dropdown" id="menu">
<a class="dropdown-toggle" data-toggle="dropdown" href="#menu">Our Services<b class="caret"></b></a>
<ul class="dropdown-menu">
<li>Registered Care</a></li>
<li>Supported Living</a></li>
<li>Vocational Services</a></li>
<li>Outreach Support</a></li>
<li>Day Activities</a></li>
<li>Therapeutic Services</a></li>
</ul>
</li>
<li class="dropdown" id="menu1">
<a class="dropdown-toggle" data-toggle="dropdown" href="#menu1">Our Homes<b class="caret"></b></a>
<ul class="dropdown-menu">
<li>Ty Newydd</a></li>
<li>Sandpiper</a></li>
<li>Woodside</a></li>
</ul>
</li>
<li class="dropdown" id="menu2">
<a class="dropdown-toggle" data-toggle="dropdown" href="#menu2">Our Team<b class="caret"></b></a>
<ul class="dropdown-menu">
<li>Our Team</a></li>
<li>Staff Vacancies</a></li>
</ul>
</li>
<li class = >Gallery</li>
<li class = >FAQ</li>
<li class = >News</li>
<li class="dropdown" id="menu4">
<a class="dropdown-toggle" data-toggle="dropdown" href="#menu4">Feedback<b class="caret"></b></a>
<ul class="dropdown-menu">
<li>Quality Reports</a></li>
<li>Care Standards</a></li>
<li>Testimonials</a></li>
</ul>
</li>
<li class = >Contact Us</li>
<li class="dropdown" id="menu3">
<a class="dropdown-toggle" data-toggle="dropdown" href="#menu3">Login<b class="caret"></b></a>
<ul class="dropdown-menu">
<div id="loginbox">
<form accept-charset="UTF-8" action="/users/sign_in" class="new_user" id="new_user" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="5174LhGldMFczTwLf9sB+I5NKs3I0rLxGoA6xq1GKKs=" /></div>
<div><label for="user_email">Email</label><br />
<input id="user_email" name="user[email]" size="30" type="email" value="" /></div>
<div><label for="user_password">Password</label><br />
<input id="user_password" name="user[password]" size="30" type="password" /></div>
<div><input name="user[remember_me]" type="hidden" value="0" /><input id="user_remember_me" name="user[remember_me]" type="checkbox" value="1" /> <label for="user_remember_me">Remember me</label></div>
<div><input name="commit" type="submit" value="Sign in" /></div>
</form>
</div>
</ul>
</li>
</div>
</div>
</ul>
</div>
</div>
</div>
For a live example you can visit
http://46.32.253.11/ .
I'm guessing as I have centered everything in my navbar then it has carried across into the nav.collapse, but I am unsure on how to get it to behave in the default way without effecting my navbar. What I would like is to have all the links align to the left within the navbar button instead of all in the center as they currently are
Whilst on the subject of the nav collapse, does any one know of any ways to customise it, for example list all the headings and then perhaps click to reveal all sub headings? Just a thought there. Anyway if anyone can offer any assistance with this it would be much appreciated
Apply your override with a media query
#media (min-width: 768px) {
.navbar.center {
...
}
}
The navbar will be centered from 768px and after.

Resources