How I can set logo like this one? (second one)
I already try but not working. My code
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand navbar-brand" href="#"><img src="img/logo.png" alt=""></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
Buy
</li>
<li>
Rent
</li>
<li>
New Properties
</li>
<li>
Property Alert
</li>
<li>
E-Learning
</li>
<li>
About Us
</li>
<li>
Contact Us
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
DEMO: https://jsbin.com/holumi/1/
https://jsbin.com/holumi/1/edit?html,css,output
The size of your logo matters, adjust the MIN-WIDTH media queries to move the logo into place.
Add navbar-custom on the navbar.
Remove the brand and navbar-brand and add logo
Adjust other CSS as needed. The CSS BEFORE the min-width media query is for all viewport sizes, the stuff INSIDE the min-width media query is for that min-width and up.
The use of position:absolute puts the logo, at that min-width, out of the document flow, therefore padding is used to put the navbar-nav into position. Notice the values.
The small viewport CSS in this example uses the same logo for both large and small, if the logo goes on dark, you can use the responsive utility classes to hide one and show the other at the min-width or max-width, such as visible-xs on the logo that is to go on the dark background and hidden-xs on the the logo for all other sizes.
CSS
.navbar-custom {
background: navy
}
.navbar-custom .logo img {
padding: 15px;
max-width: 100%;
height: auto;
}
.navbar-custom .logo {
float: left;
padding-right: 40px;
width: 100%;
}
.navbar-custom .navbar-toggle {
position: absolute;
right: 15px;
top: 15px;
border: 0px;
width: 50px;
margin: 0;
}
.navbar-custom .icon-bar {
width: 100%;
margin: 5px 0;
height: 3px;
}
#media (min-width:768px) {
.navbar-custom.navbar {
height: 200px
}
.navbar-custom .container {
position: relative;
overflow: visible;
}
.navbar-custom .navbar-nav {
padding: 125px 0 0;
text-align: center;
width: 100%;
}
.navbar-custom .navbar-nav > li {
display: inline-block;
float: none;
}
.navbar-custom .logo {
position: absolute;
background: #fff;
left: 0;
right: 0;
z-index: 5000;
display: block;
float: none;
padding: 0;
}
.navbar-custom .logo:before,
.navbar-custom .logo:after {
position: absolute;
background: #fff;
content: '';
left: -2000px;
width: 2000px;
bottom: 0;
display: block;
height: 100%;
}
.navbar-custom .logo:after {
left: auto;
right: -2000px;
}
}
HTML
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top navbar-custom" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="logo" href="#"><img src="http://placehold.it/100x75/000/FFFFFF&text=LOGO" alt=""></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
Buy
</li>
<li>
Rent
</li>
<li>
New Properties
</li>
<li>
Property Alert
</li>
<li>
E-Learning
</li>
<li>
About Us
</li>
<li>
Contact Us
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
You could just remove the brand completely from the navbar and then add a div above that navbar with an img attribute which would be your logo
Create two navbars and make top position of second navbar to start below first nav bar.
<nav class="navbar navbar-inverse navbar-fixed-top my-logo" role="navigation">
.....
</nav>
<nav class="navbar navbar-inverse navbar-fixed-top my-menu" role="navigation">
Now create style for second navbar as
.my-menu {
top: 50px;
}
Related
This question already has answers here:
Bootstrap Center Navbar Items
(5 answers)
Closed 5 years ago.
I've been trying to centre the links/tabs on my Bootstrap navbar for over a week now and it's doing my head in. Have gone through every similar question on here and absolutely nothing is working. I'm thinking I've doubled up rules somewhere along the line or am not actually targeting the right thing.
It's the basic Bootstrap navbar snippet on Dreamweaver. I've managed to customise colour/font/size, but just can't get the darn thing to sit in the middle.
.navbar.navbar-default {
background-color: #B3C5D7;
background-attachment: fixed;
position: fixed;
width: 100%;
border-radius: 0px;
float: none;
text-align: center;
}
.nav.navbar-nav {
font-size: x-large;
width: 100%;
display: inline-block;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<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="#defaultNavbar1" 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="collapse navbar-collapse" id="defaultNavbar1">
<ul class="nav navbar-nav">
<li class="active">HOME<span class="sr-only">(current)</span></li>
<li>OUR CARE FACTOR</li>
<li>FACILITIES</li>
<li>FUNCTIONS</li>
<li>CONTACT US</li>
</ul>
</div>
</div>
</div>
</nav>
You can do it with the Flexbox:
.navbar {
display: flex; /* displays flex-items (children) inline */
justify-content: center; /* centers them horizontally */
}
Try adding these classes
CSS
.navbar-header
{
float:none;
}
.navbar-nav li
{
float:none;
display:inline-block;
}
hope this helps..
Basically bootstrap using float:left in navbar-header and li so parent div doesn't accept the center alignment or margin auto so update css part which included in following snippet or check fiddle link
In first option you will get nesting classes to look css and html both carefully.
1st option with nesting class to get center
In second option you will get only css changes so check css carefully.
Second option to get center
2nd option to get center
Update css part, I am using inline-flex to get center
.navbar.navbar-default {
background-color: #B3C5D7;
background-attachment: fixed;
position: fixed;
width: 100%;
border-radius: 0px;
float: none;
text-align: center;
}
.nav.navbar-nav {
font-size: x-large;
width: 100%;
display: inline-block;
}
/* Add this css part */
.navbar-header {
float: none; /* Add this */
}
.navbar-nav li {
display: inline-flex; /* Add this */
float: none; /* Add this */
}
<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="#defaultNavbar1" 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="collapse navbar-collapse" id="defaultNavbar1">
<ul class="nav navbar-nav">
<li class="active">HOME<span class="sr-only">(current)</span></li>
<li>OUR CARE FACTOR</li>
<li>FACILITIES</li>
<li>FUNCTIONS</li>
<li>CONTACT US</li>
</ul>
</div>
</div>
</div>
</nav>
.navbar.navbar-default {
background-color: #B3C5D7;
background-attachment: fixed;
position: fixed;
width: 100%;
border-radius: 0px;
float: none;
text-align: center;
}
.nav.navbar-nav {
font-size: x-large;
width: 100%;
display: inline-block;
}
/* Add this css part */
.navbar-header.center-items {
float: none; /* Add this */
}
.navbar-center.navbar-nav li {
display: inline-flex; /* Add this */
float: none; /* Add this */
}
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header center-items"> <!--Add class -->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#defaultNavbar1" 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="collapse navbar-collapse" id="defaultNavbar1">
<ul class="nav navbar-nav navbar-center"> <!--Add class -->
<li class="active">HOME<span class="sr-only">(current)</span></li>
<li>OUR CARE FACTOR</li>
<li>FACILITIES</li>
<li>FUNCTIONS</li>
<li>CONTACT US</li>
</ul>
</div>
</div>
</div>
</nav>
Edit #1: After I give my height a definition of 89px, my mobile menu seems to go behind my content.
I'm having an issue with the mobile version of my navbar. The navbar isn't as tall as logo, so when I click on it my "Home" menu item isn't being shown unless I hover over it.
Here's the pictures for both issues:
Here's my HTML:
<nav class="navbar navbar-default navbar-static-top">
<div class="container-fluid">
<div class="row">
<div class="navbar-header">
<a class="navbar-brand " style="margin-top: -15px; float: left;" href="#">
<img alt="Brand" class="pull-left" style="margin-left: -15px;" src="Images/logo-resized.png">
</a>
<button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse">
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav">
<li>Home</li>
<li>Internet</li>
<li>Phone</li>
<li>Android TV</li>
<li>Shaw Direct</li>
<li>Contact Us</li>
</ul>
</div>
</div>
</div>
</nav>
And here's my CSS:
.navbar-default {
background-color: #00AEFE;
}
.nav.navbar-nav li a{
color: white;
font-size: 18px;
line-height: 50px;
}
.col-xs-0 {
display: none;
}
nav {
height: 89px;
}
In bootstrap navbar-brand has some padding, also the height of <img> should be controled by additional css like navbar-brand img {height:40px}.
although if we could see your live html, it was nice.
EDITED
use this CSS to give some height longer than height of your image like 100px or higher
#media (min-width: 768px) {
.navbar-header {
height: 100px;
}
}
OR
If you don't want to change the height of navbar-header you can add some padding to navbar-toggle button so it will add height of navbar-header:
#media (min-width: 768px) {
.navbar-toggle {
padding: 33px 10px;
}
}
<a class="navbar-brand " style="margin-top: -15px; float: left;height:auto" href="#">
<img alt="Brand" class="pull-left" style="margin-left: -15px;" src="Images/logo-resized.png">
</a>
Change the height of navbar-brand class
OR
<style>
.navbar-brand img {
max-height: 40px;
width: auto;
}
</style>
I do not know how I can make my navbar smaller on Ipad. As it is now, the navbar is hanging under my logo, and they should be on a row instead. I tried to set col-sm-12 because I thought everything in the div would take 12 col, but that does not work.
My website
Does anyone have an idea how I can do that?
HTML
<!-- begin nav -->
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-12">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<i class="fa fa-reorder" style="padding-left: 4px; color: red;"></i>
</button>
<!-- begin logo in navigation -->
<a class="navbar-brand" href="https://<?php echo $_SERVER['HTTP_HOST']?>/index.php">
<img src="https://<?php echo $_SERVER['HTTP_HOST']?>/images/graphic/vouzalis-webdesign.png">
</a>
<!-- end logo in navigation -->
</div>
<div class="navbar-collapse collapse">
<ul class="nav nav-pills nav-main pull-right">
<!-- begin navigation items -->
<li>
Hjem
</li>
<li>
Kompetencer
</li>
<li>
Portfolio
</li>
<li>
Om Mig
</li>
<li>
Artikler
</li>
<li>
Kontakt
</li>
<!-- end navigation items -->
</ul>
</div>
</div>
</div>
</div>
</nav>
<!-- end nav -->
CSS
#media (max-width: 767px) {
/* Navigation */
.nav-main {
float: left!important;
}
.navbar-default .navbar-collapse,
.navbar-default .navbar-form {
border: none;
}
.nav-main li:first-child {
border-top: 1px dashed #444;
}
.navbar .dropdown-menu>li>a {
padding: 15px 20px;
}
.nav-pills>li {
float: none;
}
.nav-main {
width: 100%;
}
.navbar-brand {
padding: 0px 0px 0px 15px;
}
.fixednav .nav-main {
background: #171717;
margin-top: 14px;
}
.fixednav .nav-pills>li+li {
margin-left: 0px;
}
.dropdown-menu {
float: none;
position: static;
}
You need to define your tablet breakpoint in your css.
use another media query like #media (min-width: 768px) and (max-width: 1024px) {}
define the spacing and height that you want there and it will take affect.
EDIT
I see you have a breakpoint define for min-width: 769px and max-width 991px
You can keep that breakpoint if you wish but after looking at your site the real issue is that you have your wrapping container class set to 750px and margin 0 auto to center it.
The reason your nav bar is nesting under your name element is because this container is not wide enough to display both of them inline.
You can make the container larger say 100% width and adjust your margins or make your navigation buttons smaller.
or a combination of both.
When my web page is shown on small devices the menu collapses as expected but when you click on the collapsed menu icon the menu does not appear. There is a slight adjustment of the vertical height of the page below the menu and the last menu item half appears along the top of the page but the rest of the menu is nowhere to be seen.
My Bootstrap code looks like this:
#myNavbar {
position: relative;
border:none;
}
#myNavbar .nav {
position: absolute;
bottom: 0;
right: 0;
margin-bottom: -10px;
}
.navbar-nav.navbar-right:last-child {
margin-right: 0;
}
.navbar-default {
background:#FFFFFF;
border-left:none;
border-right:none;
border-top:none;
border-bottom:solid;
border-bottom-width:2px;
border-color:#01B6AC;
width:100% !important;
margin-right:0px;
padding-right:0px;
border-radius: 0 !important;
-moz-border-radius: 0 !important;
}
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img class="img-responsive" src="/assets/img/outa.png" width="120px;"/></a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav pull-right">
<li>Saved searches</li>
<li>Settings</li>
<li>About</li>
<li>Sign In</li>
</ul>
</div>
</div>
</nav>
Anyone know what I am doing wrong?
You problem is here
#myNavbar .nav {
position: absolute;
}
When you use position:absolute; the element will be positioned absolutely from the first positioned parent div, if it can't find one it will position absolutely from the window. You can refer to THIS question for further info. So what you can do is add #media query and set a size over certain pixels where the position will be absolute. So something like
#media(min-width: 400px) {
#myNavbar .nav {
position: absolute;
bottom: 0;
right: 0;
margin-bottom: -10px;
}
}
just give proper reference of bootstrap.css and bootstrap.js and your code will work fine.
I need to modify the dropdown-menu provided in Bootstrap, using the navbar-fixed-top, to appear on hover not vertically but horizontally li { display: inline-block } (that's easy), but so I need the actual ul.dropdown-menu to stretch the full width of the page. I can't seem to figure it out.
Don't give me a megamenu plugin or anything, please, just how can I fix it to stretch the width of the whole page? (not the page container either, the window)
Will probably need to wrap another element too, actually, as the ul needs to be centered.
So does anyone know how to do this?
EDIT: Figured it out (like 5 minutes after posting this) and with no added elements:
.nav { margin-bottom: 0; }
.dropdown { position: static; }
.dropdown-menu { width: 100%; text-align: center; }
.dropdown-menu>li { display: inline-block; }
and there you have it!
First you shouldn't wrap the navbar component in a div.container then update the css with the following Code:
.nav > li.dropdown.open {
position: static;
}
.nav > li.dropdown.open .dropdown-menu {
display:table; width: 100%; text-align: center; left:0; right:0;
}
.dropdown-menu>li {
display: table-cell;
}
check the demo here http://www.bootply.com/8EgGsi4F7w
<li class="dropdown open" style="position: initial;">
<ul class="dropdown-menu" style="width: 100%;">
just use the position: initial in the main li(dropdown) of your nav and in the child ul dropdown-menu set width 100%
Here the alternative that worked for me.
I just tried option 2. The key is:
Adding class position-static along with (the) dropdown class, which is the parent class of dropdown-menu as follows:
<li class="nav-item dropdown position-static">
Credit to its author: VigneshKannan3 from GeeksforGeeks
It looks like this answer to a similar question has the same approach.
Check this
.nav > li.dropdown.open {
position: static;
}
.nav > li.dropdown.open .dropdown-menu {
display: table;
border-radius: 0px;
width: 100%;
text-align: center;
left: 0;
right: 0;
}
.dropdown-menu > li {
display: table-cell;
height: 50px;
line-height: 50px;
vertical-align: middle;
}
#media screen and (max-width: 767px) {
.dropdown-menu > li {
display: block;
}
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<div class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<div class="navbar-brand">Blackcat</div>
<button class="navbar-toggle" data-toggle="collapse" data-target=".btnCollapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse btnCollapse">
<ul class="nav navbar-nav navbar-right">
<li class="active">Shop</li>
<li class="dropdown">
Artist <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>Rich</li>
<li>Shay</li>
<li>Jose</li>
<li>Marie</li>
<li>Simon</li>
<li>Jamie</li>
<li>Andrew</li>
<li>Teddie</li>
</ul>
</li>
<li>FAQs</li>
<li>Contact</li>
</ul>
</div>
</div>
<!-- end container -->
</div>
<!-- end navbar navbar-inverse navbar-static-top -->
<!-- container -->
<div class="container">
<div class="row">
<p>Site content here...</p>
</div>
<!-- End row -->
</div>
<!-- End container -->