Navbar height ignored by Chrome and Safari - html

I found an unpleasant surprise in a local project that I'm developing, two weeks ago I visualized everything correctly but now on Chrome and Safari the height of the navbar is ignored, on Firefox instead it works all regularly as well as on Codepen. The website is based on Wordpress + Bootstrap 4
firefox vs chrome
The HTML:
<nav id="top-navbar" class="navbar sticky-top navbar-expand-lg navbar-dark animate">
<div class="container">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#bs4navbar" aria-controls="bs4navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="bs4navbar" class="collapse navbar-collapse mx-auto">
<ul id="menu-left" class="navbar-nav ml-auto"><li id="menu-item-27" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-27 nav-item">Home</li>
<li id="menu-item-28" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-23 current_page_item menu-item-28 nav-item active">About</li>
<li id="menu-item-29" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-29 nav-item dropdown">Gallery
<div class="dropdown-menu">
BespokeCollections</div>
</li>
</ul>
<a class="navbar-brand logo animate d-none d-sm-block" href="http://hebi.local">
<img class="animate" src="https://www.hsdtaxlaw.com/wp-content/uploads/2016/05/logo_placeholder.png" alt="Logo">
</a>
<ul id="menu-right" class="navbar-nav mr-0"><li id="menu-item-35" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-35 nav-item">Contact</li>
</ul>
<div class="external mr-auto">
Shop
<i class="fab fa-facebook-f"></i>
<i class="fab fa-instagram"></i>
</div>
</div>
</div>
</nav>
And the custom CSS:
.navbar {
margin:0;
border:none;
border-radius:0;
background-image: none;
text-transform: uppercase;
background: #000;
font-family: 'Cinzel', serif;
}
.logo a {
display: block;
position: relative;
max-height: 100px;
}
.logo img{
max-width: 200px;
max-height: 100px;
padding: .5rem;
-webkit-transition: all ease .2s;
transition: all ease .2s;
}
.navbar a {
color: #cc0000;
}
.navbar .btn-primary {
background: #CC0000;
border: solid #CC0000;
color: #FFF;
}
.navbar .btn-primary:hover {
background: #F81717;
border: solid #F81717;
color: #FFF;
-webkit-transition: background-color .3s ease;
transition: background-color .3s ease;
}
.navbar-nav ul{list-style-type: none}
.navbar-nav li .dropdown-menu li a{line-height: 50px; height: 50px;}
.spacer{height: 50px;}
.no-margin{margin:0; padding:0;}
.navbar li a {
-webkit-transition: color ease .2s;
transition: color ease .2s;
display: inline-block;
padding: 0 15px;
font-weight: 400;
letter-spacing: 2px;
font-style: normal;
text-transform: uppercase;
}

Well after taking a look at your code, I see you have nowhere specified any height at all. The only height specification is on the logo img element and only the max-height is defined. That could be the cause for your issue, since the height of your navbar depends on that element. Setting a fixed height or min-height to your img will solve your issue.
.logo img{
max-width: 200px;
min-height: 100px;
max-height: 100px;
padding: .5rem;
-webkit-transition: all ease .2s;
-moz-transition: all ease .2s;
-ms-transition: all ease .2s;
-o-transition: all ease .2s;
transition: all ease .2s;
}

Is there a specific reason why the navbar element does not have a height set. Setting the height will indeed help you and it will make the result look more consistent across browsers.

Related

Two-column collapsed navbar in Bootstrap 5 doesn't work

I'm making this Bootstrap 5 navbar, which should collapse at md breakpoint. After the collapse, it should show navlinks in two columns.
When I hit the breakpoint, my navbar is expanded and toggle button doesn't work.
It changes, when I switch off the display: flex property for the navbar - the collapse function works, but my ul's (in which I group li's) are in one column.
How can I reach my goal here - navbar with six elements collapses at md breakpoint and breaks the links into two columns?
<nav class="navbar navbar-expand-md navbar-light sticky-top w-100">
<div class="container-fluid">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#mainNavbar"
aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="mainNavbar">
<ul class="navUl navbar-nav">
<li class="nav-item">
<a class="nav-link text-nowrap" aria-current="page" href="/aboutMe">o mnie</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button"
data-bs-toggle="dropdown" aria-expanded="false">portfolio</a>
</li>
<li class="nav-item">
<a class="nav-link text-nowrap" href="/beforePS">przed sesją</a>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link navbar-brand" href="/">
<img src="/images/logoKP-trans.png" class="img-fluid" alt="Karolina_photography_logo" id="logo">
</a>
</li>
</ul>
<ul class="navUl navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/voucher">vouchery</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/pricing">pakiety</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/contact">kontakt</a>
</li>
</ul>
</div>
css (very messy, to be optimised):
body {
background-color: #f8edeb;
margin: 0;
font-family: "Quicksand", sans-serif;
font-weight: 400;
opacity: 0;
animation: fadeIn 0.5s;
transition: opacity 0.5s;
}
main {
align-items: center;
margin: 3% 20%;
max-width: 80%;
}
.navbar,
.footer {
background-color: #fae1dd;
color: rgba(0, 0, 0, 0.5);
box-shadow: 10px 5px 5px rgba(202, 178, 174, 0.5);
padding-top: 0;
text-align: center;
}
#mainNavbar {
display: flex;
justify-content: center;
align-items:flex-end;
}
.navbar-brand {
margin: 0;
}
.nav-item {
display: flex;
margin: 0 0.8em;
font-size: 1.2rem;
}
.navUl {
padding-bottom: 10px;
}
.navbar-brand {
max-width: 300px;
height: auto;
padding-bottom: 0;
top: 0.4rem;
}
#mainNavbar a:hover,
#socialIcons a:hover,
.loginButton a:hover {
color: white;
text-shadow: 5px 5px 10px white;
-moz-transition: all 0.2s ease-in;
-o-transition: all 0.2s ease-in;
-webkit-transition: all 0.2s ease-in;
transition: all 0.2s ease-in;
}
.dropdown-menu {
border-radius: 0.5rem;
background-color: rgba(250, 225, 221, 0.9);
}
.dropdown-item:hover {
background-color: transparent;
}
#socialIcons {
color: rgba(0, 0, 0, 0.5);
position: absolute;
top: 10px;
right: 10px;
}
#socialIcons a,
#kidsPshoot {
text-decoration: none;
color: rgba(0, 0, 0, 0.5);
display: inline;
margin-right: 0.5rem;
}
.fade_rule {
height: 1px;
background-color: #e6e6e6;
width: 50%;
margin: 0 auto;
background-image: linear-gradient(left, white 2%, #e6e6e6 50%, white 98%);
background-image: -o-linear-gradient(left, white 2%, #e6e6e6 50%, white 98%);
background-image: -moz-linear-gradient(
left,
white 2%,
#e6e6e6 50%,
white 98%
);
background-image: -webkit-linear-gradient(
left,
white 2%,
#e6e6e6 50%,
white 98%
);
background-image: -ms-linear-gradient(left, white 2%, #e6e6e6 50%, white 98%);
background-image: -webkit-gradient(
linear,
left bottom,
right bottom,
color-stop(0.02, white),
color-stop(0.5, rgb(250, 182, 170)),
color-stop(0.98, white)
);
}
#media (max-width:1200px) {
.nav-item, .dropdown-item, #aboutMeText, p, li, h5 {
font-size: 1rem;
}
#logo {
max-width: 230px;
}
.navUl {
padding-bottom: 5px;
}
}
#media (max-width:992px) {
#logo {
max-width: 200px;
/* position: absolute;
left: 70%;
top: 30%; */
}
.nav-item, .dropdown-item {
font-size: 0.9rem;
}
.nav-item {
margin: 0;
}
}
#media (max-width:768px) {
.nav-item, .dropdown-item, #navbarDropdownMenuLink, p, li {
font-size: 0.7rem;
margin-left: 0;
text-align: left;
min-width: 100px;
}
#mainNav {
position:unset;
}
}
It’s not clear what all of your CSS is for. Some, like setting the opacity on the body to 0 hide everything. It’s best to have a running snippet with your question.
If you want your logo in the center, you can split your menus into two unordered lists.
For applying margin such as to the bottom of the navbar-nav, use the Bootstrap spacing utility classes (mb-1 mb-md-2).
Copy the Bootstrap media query logic (min-width, not max-width – it’s difficult to troubleshoot with two methods) and apply your media queries starting with the smallest size (no media query), followed by increasing media query sizes (min-width: 576px, min-width: 768px, etc.).
Rather than using smaller text for smaller screens, keep the text the same size and adjust the position if the text won’t fit (smaller text is more difficult for some users to read).
One way to have two columns for the links in the collapsed version is to add a spacer div (.break) that can force the navbar-collapse divs to the next row, and then set their width to 50%.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://fonts.googleapis.com/css2?family=Quicksand&display=swap" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.1/dist/js/bootstrap.bundle.min.js"></script>
<style>
body {
background-color: #f8edeb;
font-family: "Quicksand", sans-serif;
}
.navbar,
.footer {
background-color: #fae1dd;
color: rgba(0, 0, 0, 0.5);
box-shadow: 10px 5px 5px rgba(202, 178, 174, 0.5);
padding-top: 0;
}
.navbar-brand {
margin: 0;
max-width: 300px;
height: auto;
padding-bottom: 0;
top: 0.4rem;
}
#mainNavbar a:hover,
#socialIcons a:hover,
.loginButton a:hover {
color: white;
text-shadow: 5px 5px 10px white;
-moz-transition: all 0.2s ease-in;
-o-transition: all 0.2s ease-in;
-webkit-transition: all 0.2s ease-in;
transition: all 0.2s ease-in;
}
.dropdown-menu {
border-radius: 0.5rem;
background-color: rgba(250, 225, 221, 0.9);
max-width: 75%;
}
.dropdown-item:hover {
background-color: #E0C9C5;
}
#logo {
max-width: 120px;
height: auto;
}
#media (min-width: 576px) {
#logo {
max-width: 160px;
}
}
#media (min-width: 768px) {
#logo {
max-width: 200px;
}
.navbar-collapse.flex-basis-md-0 {
flex-basis: 0;
}
}
#media (min-width: 992px) {
#logo {
max-width: 230px;
}
}
#media (min-width: 1200px) {
#logo {
max-width: 300px;
}
}
.navbar-collapse {
max-width: 50%;
}
/* Inserting div.break between two flex items will make
* the flex item that comes after it break to a new row -
* this is how the two-column navbar-collapse are moved to
* a separate row. */
.break {
flex-basis: 100%;
height: 0;
}
#media (min-width: 768px) {
.break {
display: none;
}
}
</style>
<nav class="navbar navbar-expand-md navbar-light sticky-top w-100">
<div class="container-fluid justify-content-md-around">
<a class="navbar-brand order-md-1" href="#">
<img id="logo" src="https://via.placeholder.com/120x40.png/E5FFFF/?text=KP-Trans" alt="" width="300" height="60">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".mainNavbar" aria-controls="mainNavbar1 mainNavbar2" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="break"></div>
<div class="collapse navbar-collapse flex-basis-md-0 mainNavbar" id="mainNavbar1">
<ul class="navbar-nav mx-md-auto">
<li class="nav-item">
<a class="nav-link text-nowrap" aria-current="page" href="/aboutMe">o mnie</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
portfolio
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="#">portfolio #1</a></li>
<li><a class="dropdown-item" href="#">portfolio #2</a></li>
<li><a class="dropdown-item" href="#">portfolio #3</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link text-nowrap" href="/beforePS">przed sesją</a>
</li>
</ul>
</div>
<div class="collapse navbar-collapse flex-basis-md-0 align-self-start align-self-md-center mainNavbar order-md-2" id="mainNavbar2">
<ul class="navbar-nav mx-md-auto">
<li class="nav-item">
<a class="nav-link" href="/voucher">vouchery</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/pricing">pakiety</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/contact">kontakt</a>
</li>
</ul>
</div>
</div>
</nav>
<section>
<div class="container">
<div class="row">
<div class="col vh-100">
<p class="text-center">
Center
</p>
</div>
</div>
</div>
</section>
It's also helpful if you include a placeholder image at the right size to match your logo. I guessed at 120 by 40

How to prevent a blank space when scrolling with a sidebar?

I'm currently building a sidebar using bootstrap.
I have the bar built, however when I scroll down the page, a blank space appears between the sidebar and the navbar. Is there anyway that I can make the navbar stay stationary, or fill in the blank space when the page is scrolled down? I have included screenshots and code. Normal, before scrolling
After Scrolling
Code listed below:
<nav class = "navbar navbar-inverse">
<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>
</button>
<a class = "navbar-brand" href="Home.html">Stephens Catering</a>
</div>
<div class = "collapse navbar-collapse" id="myNavbar">
<ul class = "nav navbar-nav">
<li>Home</li>
<li>About Us</li>
<li class="dropdown">
<a class = "dropdown-toggle" data-toggle="dropdown"
href="OurProducts.html">Our Products
<span class = "caret"></span></a>
<ul class = "dropdown-menu">
<li>Cookers</li>
<li>Fridges</li>
<li>Misc</li>
</ul>
</li>
<li>Contact us</li>
</ul>
<ul class = "nav navbar-nav navbar-right">
<li><a href="#"><span class="glyphicon glyphicon-user">
</span> Sign Up</a></li>
<li><a href="#"><span class="glyphicon glyphicon-log-in">
</span> Login</a></li>
</ul>
</div>
</div>
</nav>
<!--The sidebar for the products pages -->
<div id = "wrapper">
<!-- Sidebar -->
<div id = "sidebar-wrapper">
<ul class="sidebar-nav">
<li class = "sidebar-brand">
Categories
</li>
<li>
Cookers
</li>
<li>
Fridges
</li>
<li>
Misc
</li>
</ul>
</div>
<!-- Sidebar Wrapper -->
<!-- Page Content -->
<!-- Button to toggle sidebar menu -->
<div id="page-content-wrapper">
<div class="container-fluid">
<div class = "row">
<div class = "col-lg-12">
Toggle Menu
</div>
</div>
</div>
</div>
The stylesheet:
body {
overflow-x: hidden;
}
/* Toggle Styles */
#wrapper {
padding-left: 0;
-webkit-transition: all 0.5s ease;
-moz-transition:all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s;
}
#wrapper.toggled {
padding-left:250px;
}
#sidebar-wrapper {
z-index: 1000;
position:fixed;
left:250px;
width:0;
height:100%;
margin-left: -250px;
overflow-y: auto;
background: #000;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
#wrapper.toggled #sidebar-wrapper {
width:250px;
}
#page-content-wrapper {
width:100%;
position:absolute;
padding:15px;
}
#wrapper.toggled #page-content-wrapper {
position:absolute;
margin-right: -250px;
}
/* Sidebar Styles */
.sidebar-nav {
position:absolute;
top:0;
width:250%;
margin:0;
padding:0;
list-style: none;
}
.sidebar-nav li {
text-indent:20px;
line-height: 40px
}
.sidebar-nav li a {
display: block;
text-decoration: none;
color:#999999;
}
.sidebar-nav li a:hover {
text-decoration: none;
color:#fff;
background:rgba(255,255,255,0.2);
}
.sidebar-nav li a:active,
.sidebar-nav li focus {
text-decoration: none;
}
.sidebar-nav > .sidebar-brand {
height:65px;
font-size:18px;
line-height: 60px;
}
.sidebar-nav > .sidebar-brand a {
color:#999999;
}
.sidebar-nav > sidebar-brand a:hover{
color:#fff;
backround:none;
}
#media(min-width: 768px) {
#wrapper {
padding-left:0;
}
#wrapper.toggled {
padding-left:250px;
}
#sidebar-wrapper {
width:0;
}
#wrapper.toggled #sidebar-wrapper {
width:250px;
}
#page-content-wrapper {
padding:20px;
position: relative;
}
#wrapper.toggled #page-content-wrapper {
position: relative;
margin-right:0;
}
}
I think your issue is using the position:fixed in the #sidebar-wrapper css class which causes it to stick to the positioned place on the screen without scroll affect. If you want it to stick right below the top navbar then change it to position:absolute and your problem will be hopefully resolved. And if you want it to stick to top and also keep the black background of the sidebar to follow through to the bottom then change #sidebar-wrapper position:relative.
The best way for you to understand this is to understand the effects of the values of the position property. Following is a link to the w3schools definition of position property and it's values with description.
https://www.w3schools.com/cssref/pr_class_position.asp
Hope this helps.
Try adding this to your actual sidebar-wrapper css rule:
.sidebar-wrapper{
top:0;
}

Logo image to overflow menu bar

I am having difficulty getting the logo image (red) to overflow the menu bar, currently the menu bar is extended once the logo is added (see the image).
The HTML Code:
<div id="page" class="page">
<div class="pixfort_normal_1" id="section_header_2_dark">
<div class="header_nav_1 dark pix_builder_bg" style="background-image: none; background-color: rgb(13, 52, 64); padding-top: 0px; padding-bottom: 0px; box-shadow: none; border-color: rgb(255, 255, 255); background-size: auto; background-attachment: scroll; background-repeat: repeat;">
<div class="container">
<div class="sixteen columns firas2">
<nav role="navigation" class="navbar navbar-white navbar-embossed navbar-lg pix_nav_1">
<div class="containerss">
<div class="navbar-header">
<button data-target="#navbar-collapse-02" data-toggle="collapse" class="navbar-toggle pix_text" type="button">
<span class="sr-only ">Toggle navigation</span>
</button>
<img src="images/LOGO1.png" class="pix_nav_logo">
</div>
<div id="navbar-collapse-02" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active propClone">Home</li>
<li class="propClone">About</li>
<li class="propClone">Workshops and Training</li>
<li class="propClone">Contact</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container -->
</nav>
</div>
</div><!-- container -->
</div>
</div>
The CSS Code:
.pix_nav_1 ul li a {
color: rgba(0, 0, 0, 0.5);
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
};
.pix_nav_1 ul li a:hover {
//color: rgba(0,0,0,0.85);
opacity: 0.6;
}
.header_nav_1 {
padding: 0px !important;
box-shadow: none;
}
.pix_nav_logo {
background: url(../images/t_logo.png) no-repeat;
padding-top: 0px;
overflow: visible;
}
.navbar-center {margin-left: auto;margin-right: auto;float: none;position:
relative;text-align: center; }
.navbar-center li { text-align: center;float: none;display: inline-block;}
Could someone please assist me to how I can get the logo to overflow the menu. Thanks in advance!
Try this
.pix_nav_logo {
position: absolute;
}
You can adjust the logo by playing with different values for css property left and right for .pix_nav_logo.
position: absolute : The element is positioned relative to its first positioned (not static) ancestor element.
.pix_nav_logo {
background: url(../images/t_logo.png) no-repeat;
padding-top: 0px;
overflow: visible;
width: 100px; // This for your logo size
position: absolute; // This is absolute position of logo
}
.pix_nav_1 ul li a {
color: rgba(0, 0, 0, 0.5);
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
}
;
.pix_nav_1 ul li a:hover {
//color: rgba(0,0,0,0.85);
opacity: 0.6;
}
.header_nav_1 {
padding: 0px !important;
box-shadow: none;
}
.pix_nav_logo {
background: url(../images/t_logo.png) no-repeat;
padding-top: 0px;
overflow: visible;
width: 100px;
position: absolute;
}
.navbar-center {
margin-left: auto;
margin-right: auto;
float: none;
position: relative;
text-align: center;
}
.navbar-center li {
text-align: center;
float: none;
display: inline-block;
}
<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.7/js/bootstrap.min.js"></script>
<div id="page" class="page">
<div class="pixfort_normal_1" id="section_header_2_dark">
<div class="header_nav_1 dark pix_builder_bg" style="background-image: none; background-color: rgb(13, 52, 64); padding-top: 0px; padding-bottom: 0px; box-shadow: none; border-color: rgb(255, 255, 255); background-size: auto; background-attachment: scroll; background-repeat: repeat;">
<div class="container">
<div class="sixteen columns firas2">
<nav role="navigation" class="navbar navbar-white navbar-embossed navbar-lg pix_nav_1">
<div class="containerss">
<div class="navbar-header">
<button data-target="#navbar-collapse-02" data-toggle="collapse" class="navbar-toggle pix_text" type="button">
<span class="sr-only ">Toggle navigation</span>
</button>
<img src="http://www.hjmt.com/blog/wp-content/uploads/2012/08/Logo_TV_2015.png" class="pix_nav_logo">
</div>
<div id="navbar-collapse-02" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active propClone">Home</li>
<li class="propClone">About</li>
<li class="propClone">Workshops and Training</li>
<li class="propClone">Contact</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
</div>
</div>
<!-- container -->
</div>
</div>

How to center a logo in nav bar

I'm having a hard time centering a logo on the nav bar for a website I'm working on. I've tried a few things but nothing has been successful. I want to have the logo in the center of the nav bar and the other items on the left and right of it. Currently, everything is spaced out evenly, including the logo, so it is not centered. Any help would be appreciated.
HTML
<nav class="main-nav-outer" id="test">
<div class="container">
<ul class="main-nav">
<li>Home</li>
<li>Services</li>
<li>Seasonal Specials</li>
<li class="small-logo">
<img src="img/logo.png" alt="">
</li>
<li>Products</li>
<li>Team</li>
<li>Contact</li>
</ul>
<a class="res-nav_click" href="#"><i class="fa-bars"></i></a>
</div>
</nav>
CSS
.main-nav-outer{
padding:0px;
border-bottom:1px solid #dddddd;
box-shadow:0 4px 5px -3px #ececec;
position:relative;
background:#fff;
}
.main-nav{
text-align:center;
margin:10px 0 0px;
padding:0;
list-style:none;
}
.main-nav li{
display:inline;
margin:0 1px;
}
.main-nav li a{
display:inline-block;
color:#222222;
text-transform:uppercase;
font-family: 'Montserrat', sans-serif;
text-decoration: none;
line-height:20px;
margin:17px 32px;
transition:all 0.3s ease-in-out;
-moz-transition:all 0.3s ease-in-out;
-webkit-transition:all 0.3s ease-in-out;
}
.main-nav li a:hover{
text-decoration:none;
color: #ec5020;
}
.small-logo{
padding:0 32px;
margin: 0;
}
.main-section{
padding:20px 0 110px;
}
you may wanna use bootstrap and try something like this
<nav class="main-nav-outer" id="test">
<div class="container">
<ul class="main-nav">
<div class="row">
<div class="col-xs-5">
<li>Home</li>
<li>Services</li>
<li>Seasonal Specials</li>
</div>
<div class="col-xs-2">
<li class="small-logo">
<img src="img/logo.png" alt="">
</li>
</div>
<div class="col-xs-5">
<li>Products</li>
<li>Team</li>
<li>Contact</li>
</div>
</div>
</ul>
<a class="res-nav_click" href="#"><i class="fa-bars"></i></a>
</div>
</nav>
just change this selector in CSS with the below code
.main-nav li a {
display: inline-block;
color: #222222;
text-transform: uppercase;
font-family: 'Montserrat', sans-serif;
text-decoration: none;
line-height: 20px;
margin: 17px 10px;
transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-webkit-transition: all 0.3s ease-in-out;
}
HTML:
<nav class="main-nav-outer" id="test">
<div class="container">
<ul class="main-nav">
<li>Home</li>
<li>Services</li>
<li>Seasonal Specials</li>
<li class="small-logo">
<img src="img/logo.png" alt="">
</li>
<li>Products</li>
<li>Team</li>
<li>Contact</li>
</ul>
<a class="res-nav_click" href="#"><i class="fa-bars"></i></a>
</div>
</nav>
CSS:
.main-nav-outer{
padding:0px;
border-bottom:1px solid #dddddd;
box-shadow:0 4px 5px -3px #ececec;
position:relative;
background:#fff;
}
.main-nav{
margin-left:auto;
margin-right: auto;
list-style:none;
}
.main-nav li{
display:inline;
}
.main-nav li a{
display:inline-block;
color:#222222;
text-transform:uppercase;
font-family: 'Montserrat', sans-serif;
text-decoration: none;
line-height:20px;
margin:17px 32px;
transition:all 0.3s ease-in-out;
-moz-transition:all 0.3s ease-in-out;
-webkit-transition:all 0.3s ease-in-out;
}
.main-nav li a:hover{
text-decoration:none;
color: #ec5020;
}
.small-logo{
padding:0 32px;
}
.main-section{
padding:20px 0 110px;
}
Bootply
Try this:
.navbar-brand {
float: left;
text-align: center;
width: 378px;
}
.navbar-brand span {
margin: 0 auto;
text-align: center;
color:green;
}
.navbar-nav li a{
display:inline-block;
color:#222222;
text-transform:uppercase;
font-family: 'Montserrat', sans-serif;
text-decoration: none;
line-height:20px;
transition:all 0.3s ease-in-out;
-moz-transition:all 0.3s ease-in-out;
-webkit-transition:all 0.3s ease-in-out;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
<nav class="navbar navbar-fixed-top navbar-custom ">
<div class="container" >
<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>
<a class="navbar-brand visible-xs" href="#"><span class="navbar-logo">STACK OVERFLOW</span></a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-left">
<li class="active">Home</li>
<li>Menu Item 1</li>
<li>Menu Item 2</li>
</ul>
<a class="navbar-brand hidden-xs text-center" href="#"><span class="navbar-logo">STACK OVERFLOW</span></a>
<ul class="nav navbar-nav navbar-right">
<li class="active">Home</li>
<li>Menu Item 1</li>
</ul>
</div>
</div>
</nav>
When you click on Expand snippet you will see the result..

links jump out of navigation when resized (responsive)

I have two problems with my navigation in twitter bootstrap.
the links jump out of the navigation when I re-size the browser window
and 2. the collapsed navigation is hidden behind the carousel.
I want all my links in the navigation to have the same width, because they get a border in mouse-over but because of that they jump out of the navigation and are hidden behind the carousel/slider when re-sized.
They collapse just fine when re-sized to 768px but everything above that jumps out of navigation. And the other thing is that when the navigation is collapsed it is half hidden behind the carousel/slider when opened.
<nav class="navbar navbar-inverse" role="navigation">
<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 class="navbar-header">
<a class="navbar-brand" href="index.html">Test</a>
</div>
<div class="nav-collapse collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li class="span4">Home</li>
<li class="span4">Forschung</li>
<li class="span4">Fahrzeug</li>
<li class="span4">Team</li>
<li class="span4">Presse</li>
<li class="span4">Ziele</li>
<li class="span4">Karte</li>
<li class="span4">Jobs</li>
</ul>
</div>
</nav>
<div class="container">
<div id="this-carousel-id" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#this-carousel-id" data-slide-to="0" class="active"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<img src="http://placehold.it/1200x480" alt="" />
<div class="carousel-caption"><h1>Mercedes Benz</h1></div>
</div>
</div>
<a class="carousel-control left" href="#this-carousel-id" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
<a class="carousel-control right" href="#this-carousel-id" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>
</div>
</div>
and this is the css
.navbar {
height: 100px;
font-family: 'Oswald', sans-serif;
text-transform: uppercase;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
padding-right: 5%;
background-color: #000000 !important;
box-sizing: border-box;
}
.navbar-inverse .navbar-nav > li > a { color: #a2a2a2 !important }
.nav a:link,
a:visited {
line-height: 4em;
display: block;
height: 100px;
width: 120px;
text-align: center;
text-decoration: none;
}
.nav a:after {
position: absolute;
top: 100%;
left: 0;
width: 100%;
height: 1px;
background: #062d67;
content: '';
opacity: 0;
-webkit-transition: height 0.3s, opacity 0.3s, -webkit-transform 0.3s;
-moz-transition: height 0.3s, opacity 0.3s, -moz-transform 0.3s;
transition: height 0.3s, opacity 0.3s, transform 0.3s;
-webkit-transform: translateY(-10px);
-moz-transform: translateY(-10px);
transform: translateY(-10px);
}
.nav a:hover,
a:focus,
a:active {
height: 81px;
color: #ffffff !important;
background-color: #0d0d0d !important;
}
.nav a:hover:after,
.nav a:focus:after,
.nav a:active:after {
height: 18px;
opacity: 1;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
transform: translateY(0px);
}
Can anyone please point out what I did wrong?
You can't have 8 span4 elements in one row. the total sum of N in spanN must be 12 or below.
you can use span1in your case or no class on for <li> (list item) elements at all.