My "search box and social icons" are hidden behind my main-menu. This is probably because of my .hide-menu class. I have a jQuery plugin that makes the main-menu appear when scrolling-up and makes it disappear when scrolling-down.
What I want to achieve is that the "search box and social icons" DIV show always and below the main-menu. Is this possible?
My FIDDLE... FIDDLE LINK HERE
.navbar-default .navbar-nav > .active > a,.navbar-default .navbar-nav > .active > a:focus,.navbar-default .navbar-nav > .active > a:hover {
color: #fff;
}
.menu-container {
background-color: #fff;
border-bottom: 1px solid #000;
border-top: 1px solid #000;
min-height: 20px;
position: relative;
}
.navbar-nav a:hover {
color: #000;
}
.navbar-nav a:link {
font-size: 12px;
font-family: 'century schoolbook';
color: #000;
/*text-decoration: overline;
text-decoration-color: #A10000*/
}
.brand-name a {
text-decoration: none;
}
.brand-name img {
max-width: 137px;
padding: 8px;
/*position:absolute;*/
left: 0;
}
ul {
list-style-type: none;
}
.navbar-form input,.form-inline input {
width: auto;
}
#nav.affix {
position: fixed;
top: 0;
width: 100%;
z-index: 10;
}
#sidebar.affix-top {
position: static;
}
#sidebar.affix {
position: fixed;
top: 80px;
}
.navbar-default .navbar-nav > li > a {
color: #A10000;
font-family: 'LuzSans-Book';
font-size: 15px;
font-weight:bold
}
.navbar-default .navbar-nav > li > a:hover {
background-color: #A10000;
color: #000;
margin-top:4px;
margin-bottom:4px;
}
.navbar-default .navbar-nav > .active > a {
background-color: #000;
margin-top:4px;
margin-bottom:4px;
}
.navbar-custom-social {
height: 15px;
float: right;
clear: none;
margin-right: 25px;
}
.navbar-fixed-top {
padding-top: 0;
}
#search-social {
margin-bottom:20px
}
header.site_header {
box-shadow: 0 1px 6px rgba(0,0,0,.35);
width: 100%;
top: 0;
left: 0;
position: fixed;
z-index: 999;
-webkit-transition: top .5s;
transition: top .5s;
background-color: #fff;
}
header.site_header.hide-menu {
top: -90px;
}
<header class="site_header root" id="nav">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="navbar navbar-default navbar-static">
<!-- <div class="clearfix container navbar-fixed-top"> -->
<div class="clearfix menu-container">
<div class="pull-right clearfix toggle_btn_wrap">
<a class="navbar-toggle" data-target=
".navbar-collapse" data-toggle="collapse" href=
"#"><i class="fa fa-bars"></i></a>
</div>
<div class="pull-left brand-name">
<a href="#"><img alt="NAME" src=
"/images/LOGO.png"></a>
</div>
<div class="clearfix prevent-float"></div>
<div class="navbar-collapse collapse">
MENU ITEMS
</div>
</div>
</div>
</div>
</div>
</div>
</header>
<div id="search-social" class="container">
<div class="row">
<div class="col-sm-12">
<div class="navbar navbar-default navbar-static">
<div class="clearfix search_and_social">
<div class="clearfix navbar navbar-custom-search">
SEARCH BOX
</div>
<div class="clearfix navbar navbar-custom-social">
SOCIAL ICONS
</div>
</div>
</div>
</div>
</div>
</div>
Easiest is probably to use sibling selector between .site_header and #search-social. Make sure that #search-social is positioned. Something like:
#search-social {
margin-bottom: 20px;
position: relative;
}
header.site_header ~ #search-social {
top: 40px;
}
header.site_header.hide-menu ~ #search-social {
top: 0px;
}
Example (with a testbutton): https://jsfiddle.net/7f6q75h8/2/
Note: Top styling needs some adjustment depending on the menu height.
Maybe you can use position:absolute;
Else you can add a class on the wrapper when you wanna show or hide something.
.wrapper .active .div2{
display:block;
}
I don't know if this is what you want but may lead you in right direction. just added a jquery function to determine the state when menu bar is visible,
function adjustMenu() {
if (!$('#nav').hasClass('hide-menu')) {
$('#search-social').css('margin-top', $('#nav').height() + 'px');
} else {
$('#search-social').css('margin-top', '0px');
}
}
this function is called on page load as well as inside the onscroll event of page
$(window).scroll(function() {
adjustMenu();
});
here is the updated fiddle
there are better ways if you can edit in the plugin code you are using.
Related
I am trying to have a drop down menu while having a reptile image as the background, but I can't seem to have the drop down menu working with the image in it? When I take the image out, it works. I'm not sure if it's just because of the that are being mixed up, or maybe it's a typing error, but I've looked and can't find any?
Another question is why my background color gradient (the gradient not reptile.png background one) is only showing only half the page. If you make the window smaller, it shows white and doesn't look good. I've tried using width/height : 100% 100%, cover, and tried stretching the image as height but it's not working. I would like to have the image stretch to the height and width of the page. I think it may be due to something about the body height, but I am not sure how to change that.
Here is the code
header {
text-align: right;
text-shadow: none;
background-color: #a7a7a7;
}
body {
background-image: linear-gradient(#545454, #000000);
background-size: 100% 100%;
background-repeat: no-repeat;
font-family: Gill Sans, "sans-serif";
color: #f2fdec;
font-size: 3em;
text-shadow: 2px 2px 2px #000000;
padding: 0.2em;
}
img {
max-width: 100%;
max-height: 100%;
height: auto;
opacity: 0.5;
}
h3 {
font-size: 18px;
font-family:
}
nav {
font-weight: bold;
float: right;
color: #c1c1c1;
font-size: 18px;
padding: 8px 8px 8px 8px;
}
nav a:link {
color: #f3ffe7;
text-decoration: none;
}
nav a:visited {
color: #f3ffe7;
text-decoration: none;
}
nav a:hover {
color: #f3ffe7;
text-decoration: none;
}
nav ul {
list-style-type: none;
}
nav a {
text-decoration: none;
}
nav ul ul {
position: absolute;
background-color: #474747;
padding: 0;
text-align: center;
display: none;
}
nav ul ul li {
border: 1px solid #00005D;
display: block;
width: 4em;
padding-left: 1em;
margin-left: 0;
}
nav li:hover ul {
display: block;
}
footer {
font-size: 10px;
text-align: center;
background-color: #474747;
padding: 8px;
text-shadow: none;
color: #d2d2d2;
position: absolute;
left: 0;
width: 100%;
bottom: 0;
}
#wrapper {
width: 100%;
height: 100%;
}
header,
nav,
footer {
display: block;
}
.container {
position: relative;
text-align: center;
color: white;
}
.herp {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #4f4f4f;
min-width: 160px;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #696969;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #3f5840;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Reptile Website</title>
<link rel="stylesheet" href="home.css">
<meta charset="utf-8">
</head>
<body>
<div id="wrapper">
<header><nav><ul>
<div class="dropdown">
<button class="dropbtn">Home</button>
</div>
<div class="dropdown">
<button class="dropbtn">Lizards</button>
<div class="dropdown-content">
Geckos
Chameleons
Skinks
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Big Lizards</button>
<div class="dropdown-content">
Iguanas
Tegus
Monitors
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Turtles</button>
<div class="dropdown-content">
Turtles
Tortoises
Terrapins
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Snakes</button>
<div class="dropdown-content">
Colubrids
Pythons
Constrictors
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Ambibians</button>
<div class="dropdown-content">
Newts
Salamanders
Frogs and Toads
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Expertise</button>
<div class="dropdown-content">
Beginner
Intermediate
Complex
</div>
</ul></nav></header>
<div class="container">
<img src="reptile.png" alt="Reptile Background">
<div class="herp">Explore Herping<br>
<h3>Your home for Herpetology Information</h3> .
</div>
</div>
<footer>
<p>Sasha Batz | s1467218#student.mcckc.edu</p>
</footer>
</div>
</body>
</html>
First Question:
That image make its parent element .container cover the dropdown menu, so you cannot hover the dropdown menu.
You can use z-index to put it on the top:
.container {
z-index: 10;
}
.container img {
z-index: 11;
}
nav {
z-index: 1001;
}
And don't make the text Your home for Herpetology Information at the top of menu.
Second Question:
In specific, all percentage-based sizes must inherit from parent block elements, and if any of those ancestors fail to specify a size, they are assumed to be sized at 0 x 0 pixels.
So you need to add this to your css code:
html {
height: 100%;
width: 100%;
}
body {
width: 100%;
height: 100%;
}
html {
height: 100%;
}
header {
text-align : right;
text-shadow : none;
background-color : #a7a7a7;
}
body {
background-image : linear-gradient(#545454, #000000);
background-size : 100% 100%;
background-repeat : no-repeat;
font-family : Gill Sans, "sans-serif";
color : #f2fdec;
font-size : 3em;
text-shadow : 2px 2px 2px #000000;
padding: 0.2em;
height: 100%;
}
.container {
z-index: 10;
}
.container img {
z-index: 11;
}
.container .herp {
z-index: 11;
}
.container .herp h3{
z-index: 12;
}
nav {
z-index: 1001;
}
img {
max-width: 100%;
max-height : 100%;
height: auto;
opacity : 0.5;
}
h3 {
font-size : 18px;
font-family :
}
nav {
font-weight : bold;
float : right;
color : #c1c1c1;
font-size : 18px;
padding : 8px 8px 8px 8px;
}
nav a:link {
color : #f3ffe7;
text-decoration : none;
}
nav a:visited {
color : #f3ffe7;
text-decoration : none;
}
nav a:hover {
color : #f3ffe7;
text-decoration : none;
}
nav ul {
list-style-type : none;
}
nav a {
text-decoration : none;
}
nav ul ul {
position : absolute;
background-color : #474747;
padding : 0;
text-align : center;
display : none;
}
nav ul ul li {
border : 1px solid #00005D;
display : block ;
width : 4em;
padding-left : 1em;
margin-left : 0;
}
nav li:hover ul {
display : block;
}
footer {
font-size : 10px;
text-align: center;
background-color: #474747;
padding : 8px;
text-shadow : none;
color : #d2d2d2;
position : absolute;
left : 0;
width : 100%;
bottom : 0;
}
#wrapper {
width: 100%;
height : 100%;
}
header, nav, footer {
display : block;
}
.container {
position: relative;
text-align: center;
color: white;
}
.herp {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}
.dropdown {
position: relative;
display: inline-block;
z-index: 1005;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #4f4f4f;
min-width: 160px;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #696969;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #3f5840;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Reptile Website</title>
<link rel="stylesheet" href="a.css">
<meta charset="utf-8">
</head>
<body>
<div id="wrapper">
<header><nav><ul>
<div class="dropdown">
<button class="dropbtn">Home</button> |
</div>
<div class="dropdown">
<button class="dropbtn">Lizards</button> |
<div class="dropdown-content">
Geckos
Chameleons
Skinks
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Big Lizards</button> |
<div class="dropdown-content">
Iguanas
Tegus
Monitors
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Turtles</button> |
<div class="dropdown-content">
Turtles
Tortoises
Terrapins
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Snakes</button> |
<div class="dropdown-content">
Colubrids
Pythons
Constrictors
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Ambibians</button> |
<div class="dropdown-content">
Newts
Salamanders
Frogs and Toads
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Expertise</button> |
<div class="dropdown-content">
Beginner
Intermediate
Complex
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Care</button>
<div class="dropdown-content">
Leopard Gecko
Bearded Dragon
Kenyan Sand Boa
</div>
</div>
</ul></nav></header>
<div class="container">
<img src="reptile.png" alt="Reptile Background"/>
<!-- <div class="herp">Explore Herping<br>
<h3>Your home for Herpetology Information</h3></div> -->
</div>
<footer>
<p>footer</p>
</footer>
</div>
</body>
</html>
as you can see in the bottom code i create li to make list instead select option in html tag. but i get undesirable thing in appearance.
how to make li width same like bottom width. i have added value of width in css. the value 100% make li wider than bottom.
how tom make caret and number inside li position float in right. i can add class pull-rigt to make it in right position but it make caret higher than text in left position (i want make them in same middle vertical position)
.instead-option {
z-index:999;
position: absolute;
margin: 0;
max-height:300px;
background: #ffffff;
border-radius:4px;
border:1px solid #dddddd;
width:100%;
overflow:auto;
}
.instead-option > li {
width:100%;
background: #eee;
line-height: 25px;
font-size: 14px;
padding: 0 10px;
cursor: pointer;
}
.instead-option > li > a{
display: flex;
width: 100%;
}
.instead-option > li:nth-child(odd) {
background-color: #ffffff;
}
.instead-option > li:nth-child(even) {
background-color: #e5e5e5;
}
.instead-option > li:hover {
background: #aaa;
}
.instead-option > li > a{
color:#232323;
text-decoration:none;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-sm-12">
<button type="button" class="form-control text-left nominal">Pilih nominal<span class="caret caret-right"></span></button>
<ul class="instead-option list-unstyled">
<li>English <span class="text-primary pull-right">10000</span></li>
<li>Deutsch <span class="text-primary pull-right">50000</span></li>
</ul>
</div>
</div>
</div>
Since you have position: absolute; on .instead-option element, you can have another element wrapping with position: relative;.
You can use a small hack to position the caret both horizontally and vertically by using top: 50%; rule.
.instead-option {
z-index: 999;
position: absolute;
margin: 0;
max-height: 300px;
background: #ffffff;
border-radius: 4px;
border: 1px solid #dddddd;
width: 100%;
overflow: auto;
}
.instead-option > li {
width: 100%;
background: #eee;
line-height: 25px;
font-size: 14px;
padding: 0 10px;
cursor: pointer;
}
.instead-option > li > a {
display: block;
width: 100%;
}
.instead-option > li:nth-child(odd) {
background-color: #ffffff;
}
.instead-option > li:nth-child(even) {
background-color: #e5e5e5;
}
.instead-option > li:hover {
background: #aaa;
}
.instead-option > li > a {
color: #232323;
text-decoration: none;
}
.dropdown-container {
position: relative;
}
.dropdown-container .caret {
position: absolute;
/* Have the same padding to right as in the button*/
right: 12px;
/* Position the element from top by 50% of the parent element's height */
top: 50%;
/* Moves the element from its current position by -50% on Y axis to position the element vertically middle*/
transform: translateY(-50%);
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="dropdown-container">
<button type="button" class="form-control text-left nominal">Pilih nominal<span class="caret caret-right"></span>
</button>
<ul class="instead-option list-unstyled">
<li>English <span class="text-primary pull-right">10000</span>
</li>
<li>Deutsch <span class="text-primary pull-right">50000</span>
</li>
</ul>
</div>
</div>
</div>
</div>
You're using position:absolute on the .instead-option list. As such, width:100% is calculated independent of the containing div's padding value.
You can fix this by changing your css to match the padding on the col div
.instead-option {
z-index:999;
position: absolute;
margin: 0;
max-height:300px;
background: #ffffff;
border-radius:4px;
border:1px solid #dddddd;
/* width:100%; */ /* REMOVE THIS LINE */
overflow:auto;
left:15px; /* matches column left padding */
right:15px; /* matches column right padding */
}
Below is your answer. Fixed both points, See additional css added at the end of css code .
.instead-option {
z-index: 999;
position: absolute;
margin: 0;
max-height: 300px;
background: #ffffff;
border-radius: 4px;
border: 1px solid #dddddd;
width: 100%;
overflow: auto;
}
.instead-option > li {
width: 100%;
background: #eee;
line-height: 25px;
font-size: 14px;
padding: 0 10px;
cursor: pointer;
}
.instead-option > li > a {
display: flex;
width: 100%;
}
.instead-option > li:nth-child(odd) {
background-color: #ffffff;
}
.instead-option > li:nth-child(even) {
background-color: #e5e5e5;
}
.instead-option > li:hover {
background: #aaa;
}
.instead-option > li > a {
color: #232323;
text-decoration: none;
}
/*Additional Css*/
.instead-option {
width: calc(100% - 30px)
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-sm-12">
<button type="button" class="form-control text-right nominal">
<span class="pull-left">Pilih nominal</span><span class="caret caret-right"></span>
</button>
<ul class="instead-option list-unstyled">
<li>English <span class="text-primary pull-right">10000</span>
</li>
<li>Deutsch <span class="text-primary pull-right">50000</span>
</li>
</ul>
</div>
</div>
</div>
I have a top bar with a button and a navbar, for z-index reason I can only get the button working but the menu hided under the top bar or I get both but the button not clickable:
PS: I get this problem only on small display with the burger menu,
For the small device, Bootstrap uses this:
.navbar-fixed-top, .navbar-fixed-bottom {
position: fixed;
right: 0;
left: 0;
z-index: 1030;
}
If I override Z-index:1030; the bergur menu is hided under my headercss bar.
Here is my almost whole CSS, maybe some parts are not important for my problem:
HTML:
<div class="headercss navbar-fixed-top">
<div class="element"> <a class="btn btn-warning" href="www.test.com">Internet ></a></div>
</div>
<div class="sidebar-nav">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse sidebar-navbar-collapse" data-toggle="collapse" data-target=".navbar-collapse">
<ul class="nav navbar-nav">
<li>test</li>
<li>test</li>
<li>test</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
CSS:
.headercss {
width: 100%;
height: 62px;
display:block;
overflow:auto;
background-color: #CAD722;
top: -1px;
left: 0px;
position: fixed;
z-index: 100;
}
}
.btn {
font-size: 18px;
font-weight: bold;
}
/* make sidebar nav vertical */
.navbar-default .navbar-nav>li>a {
font-weight: bold;
}
#media (min-width: 768px) {
.navbar-default{
width: 200px;;
height: 100%;
background-color: #e6dfd7;
z-index: 0;
}
.sidebar-nav .navbar .navbar-collapse {
margin-top: 65px;
padding: 0;
max-height: none;
}
.sidebar-nav .navbar ul {
float: none;
display: block;
}
.sidebar-nav .navbar li {
float: none;
display: block;
}
.sidebar-nav .navbar li a {
padding-top: 12px;
padding-bottom: 12px;
font-size: 16px;
}
.sidebar-nav .navbar li a:hover {
background-color: #CAD722;
}
}
/*fixing bootstrap*/
.col-sm-10 {
width: 100%;
float: right;
}
#media (min-width: 768px){
.col-sm-10 {
width: 85%;
}
}
.navbar-default .navbar-collapse,.navbar-default .navbar-form {
border-color:#CAD722;
}
.content{
position: relative;
}
.navbar-toggle {
margin-top: 11px;
margin-bottom: 1px;
margin-left: 5px;
float: left;
}
/*For small display*/
#media (max-width: 768px) {
.navbar-default {
background-color: transparent;
border-color: transparent;
}
.sidebar-nav .navbar li{
background-color: #CAD722;
}
}
The issue is that you essentially have two full-width navbars sitting on top of each other, with one button in each. Clearly, you'll only be able to click on the top one. One solution is to add width: 50%; to .navbar-default and width: 200%; to .navbar-collapse in the small display; This causes the navbar with the menu button to only cover half of the screen, allowing you to click on the Internet button, while the collapsible menu remains full-width.
I'm trying to put a search form inline within a navbar like so:
But I end up with a navbar like this:
What I'm trying to do is have the green search bar vertically fill the whole navbar. But when I add more padding, the navbar gets more padding also. How can I do it so that the search bar fills the whole navbar like in the first example?
EDIT
Here is the Bootply with static html: http://www.bootply.com/6UyH4u0NWy#
This might get you headed in the right direction using .form-control to set the height of the input.
/* CSS used here will be applied after bootstrap.css */
/* nav */
.navbar-inverse .navbar-nav li a {
padding-top: 15px;
padding-left: 15px;
}
.navbar.navbar-inverse {
background: white;
border-bottom: solid 1px #979797;
}
.navbar-inverse .nav > li > a {
color: #858585;
font-weight: 500;
font-size: 13.5px;
}
.navbar-inverse .nav > li > a:hover,
.navbar .nav > li > a:focus {
color: black;
-webkit-transition: ease 0.2s;
transition: ease 0.2s;
}
.navbar-inverse .navbar-collapse {
border-top: none;
text-align: center;
#media (max-width: 767px) {
background-color: white;
}
}
.navbar-header h4 {
padding: 5px 0 0 10px;
}
.navbar-nav li .search-box {
height: 100%;
margin-top: none;
background-color: #38A6A6;
border: none;
color: white;
border-radius: 0;
padding-left: 15px;
padding-right: 15px;
padding-bottom: none;
}
.navbar-nav li input.search-query {
height: 100%;
padding-left: 26px;
}
.navbar-nav li form.form-search {
height: 100%;
position: relative;
}
.navbar-nav li form.form-search:before {
height: 100%;
display: block;
width: 14px;
height: 14px;
content: "\e003";
font-family: 'Glyphicons Halflings';
color: white;
background-position: -48px 0;
position: absolute;
top: 16px;
left: 8px;
z-index: 1000;
}
.navbar-nav li .form-control {
height: 50px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-fixed-top navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<h4>Brand</h4>
</div>
<ul class="nav navbar-nav navbar-right">
<li>Link
</li>
<li>Link
</li>
<li>Link
</li>
<li>Link
</li>
<li>
<form class="form-search form-inline">
<input type="text" class="search-box form-control" placeholder="Recipient's username" aria-describedby="basic-addon2" />
</form>
</li>
</ul>
</div>
</nav>
How about setting the height of .form-search to 100% ? The reason it has this current height is because its scale depends on its content (height:auto by default).
Also notice you got syntax errors in your html (closing li tag before closing form tag).
Disclaimer: Pardon my stupidity when it comes to coding. I started learning last week.
I have been tinkering around with a Bootstrap 3 template from a Youtube tutorial I found to assist me in learning HTML, CSS, and eventually Java. In this example I'm working on, I am trying to get the inline unordered list to float to the right of the page. I tried adding float:right to most of the navbar elements in the CSS, but it's not doing anything for me. Any help would be greatly appreciated.
HTML:
<div class="navbar navbar-fixed-top">
<div class="container">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button class="navbar-toggle" data-target=".navbar-responsive-collapse" data-toggle="collapse" type="button">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/"><img src="images/logo.png" alt="Your Logo"></a>
<div class="nav-collapse collapse navbar-responsive-collapse">
<ul class="nav navbar-nav">
<li class="active">
Home
</li>
<li class="inactive">
Photos
</li>
<li class="inactive">
Videos
</li>
<li class="inactive">
Contact Us
</li>
</ul>
</div><!-- end nav-collapse -->
</div><!-- end container -->
</div><!-- end navbar -->
CSS:
.navbar {
position: relative;
min-height: 50px;
padding-right: 15px;
padding-left: 15px;
margin-bottom: 20px;
background-color: #eeeeee;
border-radius: 4px;
}
.navbar:before,
.navbar:after {
display: table;
content: " ";
}
.navbar:after {
clear: both;
}
.navbar:before,
.navbar:after {
display: table;
content: " ";
}
.navbar:after {
clear: both;
}
.navbar-nav {
margin-top: 10px;
margin-bottom: 15px;
}
.navbar-nav > li > a {
padding-top: 15px;
padding-bottom: 15px;
line-height: 20px;
color: #777777;
border-radius: 4px;
}
.navbar-nav > li > a:hover,
.navbar-nav > li > a:focus {
color: #333333;
background-color: transparent;
}
.navbar-nav > .active > a,
.navbar-nav > .active > a:hover,
.navbar-nav > .active > a:focus {
color: #555555;
background-color: #d5d5d5;
}
.navbar-nav > .disabled > a,
.navbar-nav > .disabled > a:hover,
.navbar-nav > .disabled > a:focus {
color: #cccccc;
background-color: transparent;
}
.navbar-nav.pull-right {
width: 100%;
}
.navbar-static-top {
border-radius: 0;
}
.navbar-fixed-top,
.navbar-fixed-bottom {
position: fixed;
right: 0;
left: 0;
z-index: 1030;
border-radius: 0;
}
.navbar-fixed-top {
top: 0;
}
.navbar-fixed-bottom {
bottom: 0;
margin-bottom: 0;
}
.navbar-brand {
display: block;
max-width: 200px;
padding: 15px 15px;
margin-right: auto;
margin-left: auto;
font-size: 18px;
font-weight: 500;
line-height: 20px;
color: #777777;
text-align: center;
}
.navbar-brand:hover,
.navbar-brand:focus {
color: #5e5e5e;
text-decoration: none;
background-color: transparent;
}
.navbar-toggle {
position: absolute;
top: 9px;
right: 10px;
width: 48px;
height: 32px;
padding: 8px 12px;
background-color: transparent;
border: 1px solid #dddddd;
border-radius: 4px;
}
.navbar-toggle:hover,
.navbar-toggle:focus {
background-color: #dddddd;
}
.navbar-toggle .icon-bar {
display: block;
width: 22px;
height: 2px;
background-color: #cccccc;
border-radius: 1px;
}
.navbar-toggle .icon-bar + .icon-bar {
margin-top: 4px;
}
As you are using Bootstrap, to so you may use class .pull-right to align it to right.
For more info click here.
In Bootstrap v 3.** it is better practice to use "navbar-right" so the proper context should read:
ul class = "nav navbar-nav navbar-right"
If you are using bootstrap 3 the use navbar-right to pull right h
jsfiddle.net/makk/9yxeg7r5/2 - this is a similar example
<div id="top"></div>
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="row">
<div class="navbar-header">
<a class="navbar-brand" href="#top"><span class="fa fa-book fa-3x">MATH</span></a>
</div>
<ul class="nav navbar-nav navbar-right">
<li>Home</li>
<li>Features</li>
<li>Courses</li>
<li>Pricing</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>