I need Centered Logo with Bootstrap fixed top navigation. Means Brand should be come at center of navigation.
My Sample Fiddle
.LandPageNavLinks {
list-style-type:none;
margin:0;
padding:0;
}
.LandPageNavLinks > li {
float:left;
padding:15px;
margin-right:20px;
}
.LandPageNavLinks > li > a{
color:blue;
}
.LandPageNavLinks > li > a:hover {
text-decoration:none;
}
.navbar {
background:lightgray;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="navbar navbar-fixed-top">
<div class="navbar-header pull-left">
<a class="navbar-brand CenterdLogo" href="#">Brand</a>
</div>
<div class="navbar-header pull-right">
<ul class="LandPageNavLinks">
<li>
Sign Up
</li>
<li>
Log In
</li>
</ul>
</div>
</div>
.LandPageNavLinks {
list-style-type:none;
margin:0;
padding:0;
}
.LandPageNavLinks > li {
float:left;
padding:15px;
margin-right:20px;
}
.LandPageNavLinks > li > a {
color:blue;
}
.LandPageNavLinks > li > a:hover {
text-decoration:none;
}
.navbar {
background:lightgray;
}
.CenterdLogo {
position: absolute;
transform: translateX(-50%);
left: 50%;
float: none;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="navbar navbar-fixed-top">
<a class="navbar-brand CenterdLogo" href="#">Brand</a>
<div class="navbar-header pull-right">
<ul class="LandPageNavLinks">
<li>
Sign Up
</li>
<li>
Log In
</li>
</ul>
</div>
</div>
this is alternate solution for it.
.LandPageNavLinks {
list-style-type:none;
margin:0;
padding:0;
}
.LandPageNavLinks > li {
float:left;
padding:15px;
margin-right:20px;
}
.LandPageNavLinks > li > a{
color:blue;
}
.LandPageNavLinks > li > a:hover {
text-decoration:none;
}
.navbar {
background:lightgray;
position:relative;
}
.navbar-brand {
position: absolute;
left: 50%;
margin-left: -50px !important; /* 50% of your logo width */
display: block;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="navbar navbar-fixed-top">
<div class="navbar-header pull-left">
<a class="navbar-brand CenterdLogo" href="#">Brand</a>
</div>
<div class="navbar-header pull-right">
<ul class="LandPageNavLinks">
<li>
Sign Up
</li>
<li>
Log In
</li>
</ul>
</div>
</div>
i tried to fix this, it may helps you.
.navbar-header.pull-left{
float:none !important;
}
.navbar-header.pull-right{margin-top: -21px;}
a.navbar-brand.CenterdLogo{float:none;}
.LandPageNavLinks{
list-style-type:none;
margin:0;
padding:0;
}
.LandPageNavLinks > li{
float:left;
padding:15px;
margin-right:20px;
}
.LandPageNavLinks > li > a{
color:blue;
}
.LandPageNavLinks > li > a:hover{
text-decoration:none;
}
.navbar{
background:lightgray;
}
.navbar-header.pull-left{
float:none !important;
}
.navbar-header.pull-right{margin-top: -21px;}
a.navbar-brand.CenterdLogo{float:none;}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="navbar navbar-fixed-top">
<div class="navbar-header text-center pull-left">
<a class="navbar-brand CenterdLogo" href="#">Brand</a>
</div>
<div class="navbar-header pull-right">
<ul class="LandPageNavLinks">
<li>
Sign Up
</li>
<li>
Log In
</li>
</ul>
</div>
</div>
Related
I need to create a Bootstrap 4 Sidebar Menu Dropdown, as the below (image).
I'm think about use Dropright buttons, I looking for good exemples of code, but unsuccessfully...
Could any one give me a starting point? Or A funtional exemple of menu like that, with bootstrap?
Bootstrap 4 SideMenu bar with Dropdown:
Run and check out this in full page mode.
html, body {
margin:0;
padding:0;
height:100%;
}
* {box-sizing: border-box;}
.container {
height:100% !important;
margin: 0 !important;
padding: 0 !important;
}
a {
color:#fff !important;
text-decoration: none !important;
border-bottom:1px dotted #fff;
padding:0px 0px 20px 0px;
width:100%;
display:block;
height:100%;
}
li {
padding:20px 20px 0 20px;
width:100%;
list-style-type: none;
color:#fff;
}
.container ul {height:100%;}
.container > ul {
width:250px;
background-color:#225fe8;
position:relative;
padding:0 !important;
overflow:visible;
}
.container > ul > li {}
.container > ul > li:hover {background-color:#0f1e41;}
.container > ul > li > ul {
display:none;
position:absolute;
right:-250px;
top:0;
padding:0 !important;
width:250px;
background-color:#193d8e;
}
a:hover {
color: #fbfbfb !important;
}
i{
margin-top: 4px;
padding-left: 8px;
}
.container > ul > li:hover > ul {
display:block;
}
.container > ul > li > ul >li:hover {background-color:#0f1e41;}
.container > ul > li > ul > li > ul {
display:none;
position:absolute;
right:-250px;
padding:0 !important;
top:0;
width:250px;
background-color:#112551;
}
.container > ul > li > ul > li:hover ul {
display:block;
}
.container > ul > li > ul > li > ul > li:hover {background-color:#0f1e41;}
.container > ul > li > ul > li ul li ul li {
border-bottom:1px dotted #fff;
padding:20px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<div class="container">
<ul class="">
<li class="">
<a tabindex="-1" href="#">HOME <i class="fa fa-angle-right" style="font-size:20px"></i>
</a>
<ul class="">
<li class=""><a tabindex="-1" href="#">Locations</a></li>
<li class="">Strategy</li>
<li class="">Research</li>
<li class="">
Products <i class="fa fa-angle-right" style="font-size:20px"></i>
<ul class="parent">
<li >
<a href="#">
Product List
</a>
<ul class="child">
<li >Platforms</li>
<li > Funds</li>
<li >Wealth</li>
<li >Listed </li>
<li >Wealth </li>
<li >Listed</li>
<li >Listed </li>
</ul>
</li>
<li >Model Portfolios</li>
<li >Non-approved Locations</li>
</ul>
</li>
<li class="">Implementation</li>
</ul>
</li>
<li >Contact</li>
<li >Address</li>
<li >News</li>
</ul>
</div>
<script type="text/javascript">
$('.child').hide();
$('.parent').children().click(function () {
event.preventDefault();
$(this).children('.child').slideToggle('slow');
$(this).find('span').toggle();
});
</script>
</body>
check it whether it is ok or not.
Below some ajustments that I did to reach something closer to the image posted.
Thank you #Amaresh S M!
Trash:
removed tabindex -1 from html
removed i tag from css
removed the the jquery script (not necessary in this case)
In order to have a menu of 4 parts (3 dynamic and 1 fixed):
container changed from .container to .container-fluid,
to have the full width
the original container was changed to a col-9 (75% of the width)
all the .container in css was changed to col-9
was added a fixed col-3 on right (the static part of menu, 25% of the width)
each of the three parts of the col-9 has width 33.33%
the unique .row has 100% of the height
Important:
I created classes for the columns col-9 and col-3. Associate CSS to generic classes is not a good idea! This can affect the entire website.
.row-menu-full-width {
height: 100%;
}
.dynamic-part {
margin: 0 !important;
padding: 0 !important;
background-color: black;
float: left;
}
a {
color:#fff !important;
text-decoration: none !important;
border-bottom:1px dotted #fff;
padding:0px 0px 0px 0px;
width:100%;
display:block;
}
li {
list-style-type: none;
color:#fff;
padding-left: 30px;
}
.dynamic-part > ul {
width:33.33%;
height: 100%;
background-color:#225fe8;
position:relative;
padding:0 !important;
overflow:visible;
}
.dynamic-part > ul > li:hover {background-color:#0f1e41;}
.dynamic-part > ul > li > ul {
display:none;
position:absolute;
right:-100%;
top:0;
padding:0 !important;
width:100%;
background-color:#193d8e;
height: 100%;
}
a:hover {
color: #fbfbfb !important;
}
.dynamic-part > ul > li:hover > ul {
display:block;
}
.dynamic-part > ul > li > ul >li:hover {background-color:#0f1e41;}
.dynamic-part > ul > li > ul > li > ul {
display:none;
position:absolute;
right:-100%;
padding:0 !important;
top:0;
width:100%;
background-color:#112551;
height: 100%
}
.dynamic-part > ul > li > ul > li:hover ul {
display:block;
}
.dynamic-part > ul > li > ul > li > ul > li:hover {background-color:#0f1e41;}
.dynamic-part > ul > li > ul > li ul li ul li {
border-bottom:1px dotted #fff;
}
.static-part {
margin: 0 !important;
padding: 0 !important;
background-color: lightgray;
float: right;
}
<body>
<div class="container-fluid container-menu-full width">
<div class="row row-menu-full-width">
<div class="col-9 dynamic-part">
<ul class="">
<li class="">
HOME<i class="fa fa-angle-right" style="font-size:20px"></i>
<ul class="">
<li class="">Locations</li>
<li class="">Strategy</li>
<li class="">Research</li>
<li class="">
Products <i class="fa fa-angle-right" style="font-size:20px"></i>
<ul class="">
<li>
<a href="#">
Product List
</a>
</li>
<li>
<a href="#">
Product List
</a>
</li>
<li >Model Portfolios</li>
<li >Non-approved Locations</li>
</ul>
</li>
<li class="">Implementation</li>
</ul>
</li>
<li >Contact</li>
<li >Address</li>
<li >News</li>
</ul>
</div>
<div class="col-3 static-part">
fixed column
</div>
</div>
</div>
</body>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/>
i would like to know how can i change the background color when i hover over links in my bootstrap navigation bar
html:
<nav class="navbar navbar-fixed-top">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li>About me</li>
<li>Portfolio</li>
<li>Contact</li>
</ul>
</div>
</nav>
css:
.navbar{
background-color:#ff9900;
}
.navbar-nav > li > a{
color:white;
font-size:16px;
font-weight:bold;
}
.navbar-nav > li > a:hover{
color:blue;
background-color:#ff9900;
}
.navbar-default .navbar-nav > li > a:focus {
color:blue;
background-color:#ff9900;
}
Change this
.navbar-nav > li > a:hover{
color:blue;
background-color:#ff9900;
}
To this:
.navbar-nav > li > a:hover{
color:blue;
background-color:#ff9900 !important;
}
Move the background-color to the links instead of the whole navbar
Add display: block to your links (if you want the links to take the whole width)
Change your desired background-color. In the example below hotpink
.navbar{
}
.navbar-nav > li > a{
color:white;
font-size:16px;
font-weight:bold;
display: block;
background-color:#ff9900;
}
.navbar-nav > li > a:hover{
color:blue;
background-color:hotpink;
}
.navbar-default .navbar-nav > li > a:focus {
color:blue;
background-color:#ff9900;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-fixed-top">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li>About me</li>
<li>Portfolio</li>
<li>Contact</li>
</ul>
</div>
</nav>
I am trying to get all of the elements in the navbar to always display in the center of the navbar and thus the center of the page, but still they are pulling to the left. When I remove my bootstrap libary, they are centered, so there is a conflict somewhere but I am not sure what and I want to use bootstrap.
My custom CSS is also linked AFTER the bootstrap one.
Any great is greatly appreciated.
HTML:
<div class="navbar navbar-default">
<div class="container-fluid">
<div class="container">
<ul class="nav navbar-nav">
<li>Home</li>
<li>About</li>
</ul>
</div>
</div>
</div>
CSS:
.navbar {
margin-bottom: 0px;
border-radius: 0px;
}
.nav {
list-style:none;
margin:0;
padding:0;
text-align:center;
}
.nav li {
display:inline;
}
.nav a {
display:inline-block;
padding:10px;
}
.navbar-default {
background: #900000;
border: none;
}
By default, Bootstrap's css floats .navbar-nav to the left. Hence:
#media (min-width: 768px)
.navbar-nav {
float: left;
margin: 0;
}
You need to overwrite this property. I suggest giving a unique class maybe like .myNav and resetting this float. Also adding a display:inline-block
<div class="navbar navbar-default">
<div class="container-fluid">
<div class="container">
<ul class="nav navbar-nav myNav">
<li>Home</li>
<li>About</li>
</ul>
</div>
</div>
</div>
CSS:
.myNav{
float:none;
display:inline-block;
}
Finally, add a text-align:center to the wrapping navbar element to center the content inside
.navbar {
margin-bottom: 0px;
border-radius: 0px;
text-align:center;
}
Here is a possible solution:
HTML:
<div class="navbar navbar-default">
<div class="container-fluid">
<div class="container">
<ul class="nav navbar-nav navbar-center">
<li>Home</li>
<li>About</li>
</ul>
</div>
</div>
</div>
CSS:
.navbar {
margin-bottom: 0px;
border-radius: 0px;
}
.navbar-center {
width: 100%;
margin: 0 auto;
text-align: center;
text-align:center;
}
.nav li {
display:inline-block;
float: none;
}
.nav a {
padding:10px;
}
.navbar-default {
background: #900000;
border: none;
}
Fiddle: https://jsfiddle.net/j2ska9ym/
I have my logo on the left with a white background in the header but my navbar keeps going underneath this on the right. I don't understand why this is happening. Also I don't think my navbar list is going straight across.
body {
background-color: #832040;
}
.navbar-default {
width: 100%;
height: 100px;
margin: 15px 0 0;
padding: 0;
background-color: #FFF;
}
.navbar ul.nav li a {
font-family: 'Righteous', sans-serif;
font-size: 38px;
color: #000;
padding: 25px;
margin: 0;
}
.navbar ul.nav li a:hover {
background: #000;
color: #fff;
height: 40px;
}
.logo {
width: 320px;
padding: 15px;
}
<div class="navbar-default">
<div class="logo">
<img src="HairSite/KatiesKuts-Logo.png">
</div>
<div class="navbar">
<div class="navbar nav pull-right">
<ul class="nav navabar-nav">
<li>Home</li>
<li>Bio</li>
<li>Appointments</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
you have missed out some proper html structure and classes bootstrap requires.
<div class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<div class="logo">
<img src="HairSite/KatiesKuts-Logo.png">
</div>
</div>
<div class="navbar">
<ul class="nav nav navbar-nav navbar-right">
<li>Home</li>
<li>Bio</li>
<li>Appointments</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
you could refer the following links for further references;
Logo Nav by Start Bootstrap
Navbar example form Bootstrap
This might help or give you some ideas. You're missing some HTML and I don't believe navbar-default was a class in 2.3.2.
body,
html {
background-color: #832040;
}
.navbar .navbar-inner {
background: white;
border: none;
border-radius: 0;
}
.navbar .navbar-inner .nav > li > a {
font-family: 'Righteous', sans-serif;
font-size: 15px;
color: #000;
padding-top: 50px;
padding-bottom: 50px;
}
.navbar .navbar-inner .btn-navbar {
margin-top: 45px;
}
.navbar .navbar-inner .nav > li > a:hover {
background: #000;
color: #fff;
}
#media (max-width: 991px) {
.navbar .navbar-inner .nav > li > a {
padding-top: 10px;
padding-bottom: 10px;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" />
<div class="navbar">
<div class="navbar-inner">
<div class="container-fluid">
<button type="button" 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>
</button>
<a class="brand" href="#">
<img src="http://placehold.it/320x100/000">
</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li>Home
</li>
<li>Bio
</li>
<li>Appointments
</li>
<li>Contact
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
</div>
I want to make a navigation bar. I supposed a big block would be shown when i hover a the nav bar. However, it didn't work.
This is my html code.
<div id="outerContainer">
<div id="header">
<a id="logo" href="#"><img src="#"></a>
<div id="nav">
<div class="selectors">aaa</div>
<div class="selectors">bbb</div>
<div class="selectors">ccc</div>
<div class="selectors">ddd</div>
</div>
</div>
<div id="innerContainer">
<div class="navHidden"></div>
<div class="navHidden"></div>
<div class="navHidden"></div>
<div class="navHidden"></div>
<div id="content"></div>
</div>
And, this is my css.
#nav{
position:relative;
float:left;
width:600px;
padding-left:30px;
padding-top:25px;
}
.selectors{
width:150px;
position:relative;
float:left;
margin:0;
z-index:10px;
}
.selectors:hover{border-bottom-color:silver;background-color:silver;}
.navHidden{
width:760px;
height:100px;
background-color:silver;
position:absolute;
z-index:10;
display:none;
visibility:hidden;
}
I want the web become as follow:
|.selectors |.selectors | .selectors | .selectors |
| navHidden .....(only shown when hover)......|
I can only allowed to use html and css, because this is homework.
Thanks.
Your code was adapted so now your have desired layout. But it is NOT PERFECT I did not remove excess rules. Do your homework by yourself
HTML
<div id="header">
<a id="logo" href="#"><img src="#"></a>
<div id="nav">
<div class="selectors">
aaa
<div class="navHidden">Lorem ipsum text</div>
</div>
<div class="selectors">
bbb
<div class="navHidden">Lorem ipsum text</div>
</div>
<div class="selectors">
ccc
<div class="navHidden">Lorem ipsum text</div>
</div>
<div class="selectors">
ddd
<div class="navHidden">Lorem ipsum text</div>
</div>
</div>
</div>
CSS
#nav{
position:relative;
float:left;
width:600px;
padding-left:30px;
padding-top:25px;
}
.selectors{
width:150px;
position:relative;
float:left;
margin:0;
z-index:10px;
}
.selectors:hover{
border-bottom-color:silver;
background-color:silver;
}
.navHidden{
width:760px;
height:100px;
background-color:silver;
position:absolute;
z-index:10;
display:none;
top: 100%;
left: 0;
}
.selectors:hover .navHidden {display: block;}
Try this way to create your navigation.
<style>
ul, li {list-style: none; padding: 0; margin: 0; float: left;}
li a{display: block; width: 100px; height: 40px;}
li a:hover{display: block; width: 100px; height: 40px; background: red;}
li ul {display: none;}
li:hover ul {display: block;}
</style>
</head>
<ul id="nav">
<li class="selectors">aaa</li>
<li class="selectors">bbbb
<ul id="innerContainer">
<li class="navHidden">222</li>
</li>
</ul>
</li>
</ul>