I want a responsive navbar with 4 links and a brand logo in the middle. I want the navbar centered in the middle of the browser. But I'm having trouble executing that layout.
How can I achieve it?
.navbar-header {
min-height: 150px;
}
.navbar {
background: transparent;
min-height: 113px;
top: 0px;
font-size: 18px;
width: auto;
border: none;
padding: 0px 0px;
}
.navbar-default .navbar-nav > li > a {
color: #fff;
}
.navbar-brand {
padding: 0 15px;
height: 113px;
}
#media (min-width: 768px) {
.navbar-nav {
position: relative;
right: -50%;
}
.navbar-nav > li {
position: relative;
left: -50%;
}
.navbar-nav > li a {
line-height: 113px;
vertical-align: middle;
padding: 0 24px;
}
}
#media (min-width: 992px) {
.navbar-nav > li a {
padding: 0 48px;
}
}
#media (min-width: 1200px) {
.navbar-nav > li a {
padding: 0 68px;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<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://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" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Navigation ein-/ausblenden</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand hidden-sm hidden-md hidden-lg" href="#">
<img src="images/brand.png" alt="Brand" width="310" />
</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li>Start
</li>
<li>Idee
</li>
<li class="hidden-xs">
<a href="#">
<img src="images/brand.png" alt="Brand" width="310" />
</a>
</li>
<li>Leistungen
</li>
<li>Kontakt
</li>
</ul>
</div>
</div>
</nav>
I hope this will help
.navbar-header {
min-height: 150px;
}
.navbar {
background: transparent;
min-height: 113px;
top: 0px;
font-size: 18px;
width: auto;
border: none;
padding: 0px 0px;
}
.navbar-default .navbar-nav > li > a {
color: #fff;
}
.navbar-brand {
padding: 0 15px;
height: 113px;
}
#media (min-width: 768px) {
.navbar-nav {
position: relative;
right: -50%;
}
.navbar-nav > li {
position: relative;
left: -50%;
}
.navbar-nav > li a {
line-height: 113px;
vertical-align: middle;
padding: 0 24px;
}
}
#media (min-width: 992px) {
.navbar-nav > li a {
padding: 0 48px;
}
}
#media (min-width: 1200px) {
.navbar-nav > li a {
padding: 0 68px;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<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://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div class="container-fluid text-center">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Navigation ein-/ausblenden</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand hidden-sm hidden-md hidden-lg" href="#"><img src="images/brand.png" alt="Brand" width="310"/></a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li>Start</li>
<li>Idee</li>
<li class="hidden-xs"><img src="images/brand.png" alt="Brand" width="310" /></li>
<li>Leistungen</li>
<li>Kontakt</li>
</ul>
</div>
</div>
</nav>
</div>
I suggest you to don't edit bootstrap styles, use your own class.
.navbar-brand {
transform: translateX(-50%);
left: 50%;
position: absolute;
}
Related
I've got an annoying space between the navbar and an <h1> header, at the top of the page, that I can't seem to get rid of. I've tried .navbar { margin-bottom: 0; } and section#title-bar { margin-top: 0; }. But, the gap doesn't go away. I'm using bootstrap 4.
Here's my code:
body {
background: #FFF;
padding-top: 4rem; }
body .navbar {
margin-bottom: 0px; }
body .green-text {
color: #1CAA98 !important; }
body .jumbotron {
background: url(../img/site_showcase_bg.jpg) no-repeat top center;
color: #FFF;
height: 500px;
overflow: none; }
body .jumbotron img.app-btn {
width: 40%;
margin-right: 30px;
display: inline; }
body .jumbotron h1 {
margin-top: 60px; }
body .jumbotron p {
margin-bottom: 40px; }
body .jumbotron img.showCase-img {
max-width: 100%; }
body section#middle {
padding: 10px 0 40px 0; }
body section#middle img.demo-1 {
width: 100%;
padding: 3px;
border: 1px solid #CCC; }
body section#middle img.demo-2 {
width: 100%;
padding: 3px;
border: 1px solid #CCC; }
body section#middle img.demo-3 {
width: 100%;
padding: 3px;
border: 1px solid #CCC; }
body section#feature {
background: #1CAA98;
color: #FFF;
padding: 40px;
overflow: auto; }
body section#feature ul li {
font-size: 22px;
list-style: none; }
body section#feature .big-logo {
width: 100%; }
body section#title-bar {
height: 80px;
background: #1CAA98;
color: #FFF;
padding: 0;
margin: 0; }
body footer {
background: #333;
color: #FFF;
padding: 30px 0 20px 0; }
body footer li {
float: left;
padding: 0 10px 0 10px;
list-style: none; }
body footer a {
color: #FFF; }
body footer p {
float: right; }
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Adding Font Awesome icons to the app -->
<script src="https://use.fontawesome.com/7333e518d7.js"></script>
<title>Gamma: About</title>
<!-- Bootstrap core CSS -->
<link href="./css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="./css/styles.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand green-text" href="#">Gamma</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="index.html">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link" href="about.html">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">Contact</a>
</li>
</ul>
</div>
</nav>
<section id="title-bar">
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>About Gamma</h1>
</div>
</div>
</div>
</section>
</body>
</html>
Maybe I've overlooked something. Any help is appreciated.
You need to remove the top margin from the h1 tag itself and the bottom margin from the navbar-nav ul list, which is there by default browser styles.
This is due to padding-top: 4em; on the body, You need to use 56px (height of the navbar) instead, like:
body {
padding-top: 56px; // Height of the navbar
}
Have a look at the snippet below:
body {
background: #FFF;
padding-top: 56px; }
body .navbar {
margin-bottom: 0px; }
body .green-text {
color: #1CAA98 !important; }
body .jumbotron {
background: url(../img/site_showcase_bg.jpg) no-repeat top center;
color: #FFF;
height: 500px;
overflow: none; }
body .jumbotron img.app-btn {
width: 40%;
margin-right: 30px;
display: inline; }
body .jumbotron h1 {
margin-top: 60px; }
body .jumbotron p {
margin-bottom: 40px; }
body .jumbotron img.showCase-img {
max-width: 100%; }
body section#middle {
padding: 10px 0 40px 0; }
body section#middle img.demo-1 {
width: 100%;
padding: 3px;
border: 1px solid #CCC; }
body section#middle img.demo-2 {
width: 100%;
padding: 3px;
border: 1px solid #CCC; }
body section#middle img.demo-3 {
width: 100%;
padding: 3px;
border: 1px solid #CCC; }
body section#feature {
background: #1CAA98;
color: #FFF;
padding: 40px;
overflow: auto; }
body section#feature ul li {
font-size: 22px;
list-style: none; }
body section#feature .big-logo {
width: 100%; }
body section#title-bar {
height: 80px;
background: #1CAA98;
color: #FFF;
padding: 0;
margin: 0; }
body footer {
background: #333;
color: #FFF;
padding: 30px 0 20px 0; }
body footer li {
float: left;
padding: 0 10px 0 10px;
list-style: none; }
body footer a {
color: #FFF; }
body footer p {
float: right; }
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Adding Font Awesome icons to the app -->
<script src="https://use.fontawesome.com/7333e518d7.js"></script>
<title>Gamma: About</title>
<!-- Bootstrap core CSS -->
<link href="./css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="./css/styles.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand green-text" href="#">Gamma</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="index.html">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link" href="about.html">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">Contact</a>
</li>
</ul>
</div>
</nav>
<section id="title-bar">
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>About Gamma</h1>
</div>
</div>
</div>
</section>
</body>
</html>
Hope this helps!
I have made this div responsive in Bootstrap. But, the styling and formatting doesn't look quite right. When you click on the expand button, I feel like the "Sign Up" and "Login" sections should be in a separate section from the blue and the lines look messed up. How can I make this nav look more responsive and professional?
.navbar {
background: #007BC4 !important;
padding: 10px !important;
}
.nav a {
color: white !important;
}
#sign_up {
position: absolute;
left: 100%;
top: 100%;
transform: translatex(-50%);
}
#email_form, #password_form {
padding: 5px;
font-family: 'Open Sans', sans-serif;
border-radius: 3px;
border: 1px solid #007BC4;
}
#login_button {
background: #0092ea !important;
border: 1px solid #005c93;
font-weight: bold;
font-size: 14px !important;
}
#login_button:hover {
background: #007BC4 !important;
}
#remember_label {
color: white !important;
font-weight: normal !important;
font-size: 13px;
font-family: 'Open Sans', sans-serif;
}
#forgot_password {
color: white !important;
position: relative;
left: 65px;
font-size: 13px !important;
}
#remember {
position: relative;
top: 2px;
}
.navbar-brand{
height:auto;
padding: 0px 15px;
}
.navbar-brand img{ max-width:250px;width:100%;}
.navbar-nav > li > a{padding-top: 0;}
#media (max-width:1000px) {
.navbar-header {
float: left;
width:25%;
}
.navbar-brand{
width: 100%;
margin-top: 12px;
padding:0;
}
}
#media (max-width:767px) {
.navbar-header {
float: left;
width:100%;
margin-left: 0 !important;
}
.navbar-brand{
width: auto;
margin-top: 0px;
}
.navbar-brand img {
max-width: 200px;
}
.navbar-nav {
width: 100%;
float: left;
margin: 7.5px 0;
}
.navbar-nav > li > a{
padding: 10px 0;
}
.navbar-form{
float: left;
}
#sign_up {
position: relative;
left: 50%;
top: 0;
width: 100%;
padding: 8px 0px;
}
#email_form, #password_form{
margin-bottom: 5px;
width: 100%;
}
#login_button{
width: 100%;
}
}
<!-- CSS Files -->
<link rel='stylesheet' href='http://netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css'>
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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="navbar-brand" rel="home" href="#" title="Buy Sell Rent Everyting">
<img src="https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-logo.png?v=9c558ec15d8a">
</a>
</div>
<!-- Sign Up -->
<div id="navbar" class="collapse navbar-collapse navbar-responsive-collapse">
<ul class="nav navbar-nav">
<li> <button class="btn btn-success btn-sm" id='sign_up'> Sign Up </button> </li>
</ul>
<!-- Login -->
<div class='navbar-form navbar-right'>
<form action='#' method='post'>
<input type='text' placeholder='Email' id='email_form'>
<input type='text' placeholder='Password' type='password' id='password_form'>
<button class="btn btn-primary btn-sm" id='login_button'>Login</button>
</form>
<input type='checkbox' name='remember' id='remember'> <label for='remember' id='remember_label'> Remember me </label>
<a href='#' id='forgot_password'> Forgot Password? </a>
</div>
</div>
</div>
</div>
<!-- JS Files -->
<script src='http://code.jquery.com/jquery-1.11.1.min.js'></script>
<script src='http://netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js'></script>
do you mean like making your button responsive? if your using css, i'm guessing you know html right? make a link. thats what i'm suggesting. and to make it look professional, you basically just have to rely on gut instinct. (colors dude, what colors are professional anyway, beige?)
I've never used Bootstrap and I'm trying to make my nav responsive. I've make my nav responsive, but it's not formatted correctly. The logo is not centered and when the section is expanded, all the content is messy. How do I make the content look more professional?
/* Navigation */
.navbar {
background: #007BC4 !important;
padding: 10px !important;
}
.nav a {
color: white !important;
}
#sign_up {
position: absolute;
left: 100%;
top: 100%;
transform: translatex(-50%);
}
#email_form, #password_form {
padding: 5px;
font-family: 'Open Sans', sans-serif;
border-radius: 3px;
border: 1px solid #007BC4;
}
#login_button {
background: #0092ea !important;
border: 1px solid #005c93;
font-weight: bold;
font-size: 14px !important;
}
#login_button:hover {
background: #007BC4 !important;
}
#remember_label {
color: white !important;
font-weight: normal !important;
font-size: 13px;
font-family: 'Open Sans', sans-serif;
}
#forgot_password {
color: white !important;
position: relative;
left: 65px;
font-size: 13px !important;
}
#remember {
position: relative;
top: 2px;
}
/* End of Navigation */
<!DOCTYPE html>
<html>
<head>
<!-- CSS Files -->
<link rel='stylesheet' href='http://netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css'>
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
</head>
<body>
<!-- navigation -->
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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="navbar-brand" rel="home" href="#" title="Buy Sell Rent Everyting">
<img style="max-width: 250px; margin-top: -5px;"
src="https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-logo.png?v=9c558ec15d8a">
</a>
</div>
<!-- Sign Up -->
<div id="navbar" class="collapse navbar-collapse navbar-responsive-collapse">
<ul class="nav navbar-nav">
<li> <button class="btn btn-success btn-sm" id='sign_up'> Sign Up </button> </li>
</ul>
<!-- Login -->
<div class='navbar-form navbar-right'>
<form action='#' method='post'>
<input type='text' placeholder='Email' id='email_form'>
<input type='text' placeholder='Password' type='password' id='password_form'>
<button class="btn btn-primary btn-sm" id='login_button'>Login</button>
</form>
<input type='checkbox' name='remember' id='remember'> <label for='remember' id='remember_label'> Remember me </label>
<a href='#' id='forgot_password'> Forgot Password? </a>
</div>
</div>
</div>
</div>
<!-- end of navigation -->
<!-- JS Files -->
<script src='http://code.jquery.com/jquery-1.11.1.min.js'></script>
<script src='http://netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js'></script>
</body>
<script type="text/javascript">
</script>
</body>
</html>
I have tried to give professional look. please find the code here:
.navbar {
background: #007BC4 !important;
padding: 10px !important;
}
.nav a {
color: white !important;
}
#sign_up {
position: absolute;
left: 100%;
top: 100%;
transform: translatex(-50%);
}
#email_form, #password_form {
padding: 5px;
font-family: 'Open Sans', sans-serif;
border-radius: 3px;
border: 1px solid #007BC4;
}
#login_button {
background: #0092ea !important;
border: 1px solid #005c93;
font-weight: bold;
font-size: 14px !important;
}
#login_button:hover {
background: #007BC4 !important;
}
#remember_label {
color: white !important;
font-weight: normal !important;
font-size: 13px;
font-family: 'Open Sans', sans-serif;
}
#forgot_password {
color: white !important;
position: relative;
left: 65px;
font-size: 13px !important;
}
#remember {
position: relative;
top: 2px;
}
.navbar-brand{
height:auto;
padding: 0px 15px;
}
.navbar-brand img{ max-width:250px;width:100%;}
.navbar-nav > li > a{padding-top: 0;}
#media (max-width:1000px) {
.navbar-header {
float: left;
width:25%;
}
.navbar-brand{
width: 100%;
margin-top: 12px;
padding:0;
}
}
#media (max-width:767px) {
.navbar-header {
float: left;
width:100%;
margin-left: 0 !important;
}
.navbar-brand{
width: auto;
margin-top: 0px;
}
.navbar-brand img {
max-width: 200px;
}
.navbar-nav {
width: 100%;
float: left;
margin: 7.5px 0;
}
.navbar-nav > li > a{
padding: 10px 0;
}
.navbar-form{
float: left;
}
#sign_up {
position: relative;
left: 50%;
top: 0;
width: 100%;
padding: 8px 0px;
}
#email_form, #password_form{
margin-bottom: 5px;
width: 100%;
}
#login_button{
width: 100%;
}
}
<!-- CSS Files -->
<link rel='stylesheet' href='http://netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css'>
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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="navbar-brand" rel="home" href="#" title="Buy Sell Rent Everyting">
<img src="https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-logo.png?v=9c558ec15d8a">
</a>
</div>
<!-- Sign Up -->
<div id="navbar" class="collapse navbar-collapse navbar-responsive-collapse">
<ul class="nav navbar-nav">
<li> <button class="btn btn-success btn-sm" id='sign_up'> Sign Up </button> </li>
</ul>
<!-- Login -->
<div class='navbar-form navbar-right'>
<form action='#' method='post'>
<input type='text' placeholder='Email' id='email_form'>
<input type='text' placeholder='Password' type='password' id='password_form'>
<button class="btn btn-primary btn-sm" id='login_button'>Login</button>
</form>
<input type='checkbox' name='remember' id='remember'> <label for='remember' id='remember_label'> Remember me </label>
<a href='#' id='forgot_password'> Forgot Password? </a>
</div>
</div>
</div>
</div>
<!-- JS Files -->
<script src='http://code.jquery.com/jquery-1.11.1.min.js'></script>
<script src='http://netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js'></script>
FRONT END FOR NAVBAR
<nav class="navbar navbar-default" role="navigation" style="background-color: #FFFFFF">
<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">
<asp:ImageButton ID="imglogo" runat="server" ImageUrl="~/Images/logo 1 copy 4-1.jpg" AlternateText="LOGO" CausesValidation="False" OnClick="imgblogo_Click" PostBackUrl="~/Home.aspx" CssClass="img img-responsive logo" />
</a>
</div>
<div class="collapse navbar-collapse" id=".navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<h4>CATEGORY<b class="caret"></b></h4>
</a>
<ui>...........</ui>
</li>
<li>
<a href="#">
<h4>SHIRT</h4>
</a>
</li>
<li>
<a href="#">
<h4>PANTS</h4>
</a>
</li>
<li>
<a href="#">
<h4>SHOE</h4>
</a>
</li>
<li>
<a href="#">
<h4>FASHION</h4>
</a>
</li>
<li>
<a href="#">
<h4>PAPER QULING</h4>
</a>
</li>
<li>
<a href="#">
<h4>TERRACOTA</h4>
</a>
</li>
<li>
<a href="#">
<h4>MEENAKARI</h4>
</a>
</li>
<li>
<a href="#">
<h4>TRADITIONAL</h4>
</a>
</li>
<li>
<a></a>
</li>
</ul>
</ul>
</div>
<br />
</nav>
When i decrease size of google chrome the category and other stuff overlaps logo at width:1502px
I have tried this css
#media (max-width:1502px){
.navbar-brand {
height: 80px;
}
.navbar {
background-color: #ccc;
}
.navbar-toggle {
margin-top: 25px;
}
}
IMAGE : IMAGE OF NAVBAR
Because you have so many links inside your nav and due to the increased font size it's overflowing since there simply is not enough space the smaller the viewport gets.
You can change the breakpoint that the navbar collapses, additionally you can change the display property of the links so they wrap. This will leave them exposed longer but you'll still need to collapse the nav earlier then normal.
Example I:
.navbar.navbar-tall {
background-color: white;
}
.navbar.navbar-tall .navbar-nav > li > a {
text-transform: uppercase;
font-size: 20px;
font-weight: bold;
}
.navbar.navbar-tall .navbar-brand {
padding-top: 5px;
}
.navbar.navbar-tall .navbar-brand img {
height: 90px;
}
#media (min-width: 1505px) {
.navbar.navbar-tall .navbar-nav > li > a {
line-height: 70px;
}
}
/*CSS TO CHANGE COLLAPSE BREAKPOINT STARTS HERE*/
#media (max-width: 1504px) and (min-width: 768px) {
.navbar.navbar-fixed-bottom .navbar-collapse,
.navbar.navbar-fixed-top .navbar-collapse {
max-height: auto;
overflow-x: visible;
}
}
#media (max-width: 1504px) {
.navbar .navbar-header {
float: none;
min-height: 100px;
}
.navbar .navbar-left,
.navbar .navbar-right {
float: none !important;
}
.navbar .navbar-right {
margin-right: 0px;
}
.navbar .navbar-right~.navbar-right {
margin-right: 0;
}
.navbar .navbar-toggle {
display: block;
margin-top: 32.5px;
}
.navbar .navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.navbar.navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
.navbar .navbar-collapse.collapse {
display: none!important;
overflow: visible!important;
}
.navbar .navbar-nav {
float: none!important;
margin-top: 7.5px;
}
.navbar .navbar-nav>li {
float: none;
}
.navbar .navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.navbar .collapse.in {
display: block !important;
overflow-y: auto;
}
.navbar .navbar-nav .dropdown-menu > li > a,
.navbar .navbar-nav .dropdown-menu > li > a:hover,
.navbar .navbar-nav .dropdown-menu > li > a:focus {
color: #777;
}
.navbar .navbar-nav .open .dropdown-menu {
position: static;
float: none;
width: auto;
margin-top: 0;
background-color: transparent;
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
}
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<nav class="navbar navbar-default navbar-tall" role="navigation">
<div class="container-fluid">
<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">
<img src="http://wallpapercave.com/wp/Tk48wK7.png" alt="Brand Name">
</a>
</div>
<div class="collapse navbar-collapse" id=".navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
CATEGORY <span class="caret"></span>
<ul class="dropdown-menu">
<li>LINK
</li>
</ul>
</li>
<li>
SHIRT
</li>
<li>
PANTS
</li>
<li>
SHOE
</li>
<li>
FASHION
</li>
<li>
PAPER QULING
</li>
<li>
TERRACOTA
</li>
<li>
MEENAKARI
</li>
<li>
TRADITIONAL
</li>
</ul>
</div>
</div>
</nav>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
Example II: Wrapped Links
.navbar.navbar-tall {
background-color: white;
}
.navbar.navbar-tall .navbar-nav > li > a {
text-transform: uppercase;
font-size: 20px;
font-weight: bold;
}
.navbar.navbar-tall .navbar-brand {
padding-top: 5px;
}
.navbar.navbar-tall .navbar-brand img {
height: 90px;
}
#media (min-width: 1500px) {
.navbar.navbar-tall .navbar-nav > li > a {
line-height: 70px;
}
}
#media (max-width: 1499px) and (min-width: 1000px) {
.navbar.navbar-tall .navbar-nav {
display: table;
float: none;
}
.navbar.navbar-tall .navbar-nav > li {
display: table-cell;
}
}
/*CSS TO CHANGE COLLAPSE BREAKPOINT STARTS HERE*/
#media (max-width: 1499px) and (min-width: 1000px) {
.navbar.navbar-fixed-bottom .navbar-collapse,
.navbar.navbar-fixed-top .navbar-collapse {
max-height: auto;
overflow-x: visible;
}
}
#media (max-width: 999px) {
.navbar .navbar-header {
float: none;
min-height: 100px;
}
.navbar .navbar-left,
.navbar .navbar-right {
float: none !important;
}
.navbar .navbar-right {
margin-right: 0px;
}
.navbar .navbar-right~.navbar-right {
margin-right: 0;
}
.navbar .navbar-toggle {
display: block;
margin-top: 32.5px;
}
.navbar .navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.navbar.navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
.navbar .navbar-collapse.collapse {
display: none!important;
overflow: visible!important;
}
.navbar .navbar-nav {
float: none!important;
margin-top: 7.5px;
}
.navbar .navbar-nav>li {
float: none;
}
.navbar .navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.navbar .collapse.in {
display: block !important;
overflow-y: auto;
}
.navbar .navbar-nav .dropdown-menu > li > a,
.navbar .navbar-nav .dropdown-menu > li > a:hover,
.navbar .navbar-nav .dropdown-menu > li > a:focus {
color: #777;
}
.navbar .navbar-nav .open .dropdown-menu {
position: static;
float: none;
width: auto;
margin-top: 0;
background-color: transparent;
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
}
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<nav class="navbar navbar-default navbar-tall" role="navigation">
<div class="container-fluid">
<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">
<img src="http://wallpapercave.com/wp/Tk48wK7.png" alt="Brand Name">
</a>
</div>
<div class="collapse navbar-collapse" id=".navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
CATEGORY <span class="caret"></span>
<ul class="dropdown-menu">
<li>LINK
</li>
</ul>
</li>
<li>
SHIRT
</li>
<li>
PANTS
</li>
<li>
SHOE
</li>
<li>
FASHION
</li>
<li>
PAPER QULING
</li>
<li>
TERRACOTA
</li>
<li>
MEENAKARI
</li>
<li>
TRADITIONAL
</li>
</ul>
</div>
</div>
</nav>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
Maybe this is what you are looking for:
.navbar-brand {
padding: 0px !important;
}
.navbar-brand > img {
height: 100%;
width: auto;
}
#media (min-width:768px) {
.navbar-brand {
padding: 15px 0px 0px 0px !important;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-default" role="navigation" style="background-color: #FFFFFF">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" 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">
<!--start - only for test pupose-->
<img alt="Brand" src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTAUTCWRBOD3bLFlPjl_MsOm3-E8X0P3prqoSNRr6B_jJluRyiy" class="img img-responsive logo">
<!--start - only for test pupose-->
<asp:ImageButton ID="imglogo" runat="server" ImageUrl="~/Images/logo 1 copy 4-1.jpg" AlternateText="LOGO" CausesValidation="False" OnClick="imgblogo_Click" PostBackUrl="~/Home.aspx" CssClass="img img-responsive logo" />
</a>
</div>
<div class="navbar-collapse collapse" id=".navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<h4>CATEGORY<b class="caret"></b></h4>
</a>
</li>
<li>
<a href="#">
<h4>SHIRT</h4>
</a>
</li>
<li>
<a href="#">
<h4>PANTS</h4>
</a>
</li>
<li>
<a href="#">
<h4>SHOE</h4>
</a>
</li>
<li>
<a href="#">
<h4>FASHION</h4>
</a>
</li>
<li>
<a href="#">
<h4>PAPER QULING</h4>
</a>
</li>
<li>
<a href="#">
<h4>TERRACOTA</h4>
</a>
</li>
<li>
<a href="#">
<h4>MEENAKARI</h4>
</a>
</li>
<li>
<a href="#">
<h4>TRADITIONAL</h4>
</a>
</li>
<li><a></a></li>
</ul>
</div>
</div>
</nav>
When viewed on mobile devices I would like my navbar not to collapse, but stay as in the original desktop website. I have achieved this by overwriting the CSS in a media screen (code below). I would like, however, the navbar to stretch across the whole width, and this I cannot achieve.
I tried changing background-color of navbar-default to black, but it adds some margin which I can't seem to remove.
#media screen
and (min-width: 320px)
and (max-width: 767px)
and (orientation: landscape) {
body{
margin: 0 auto;
background-image: url(../images/background_vm.jpg);
/*background-repeat:no-repeat;*/
background-attachment: fixed;
background-size:100% auto;
font-family: 'Tinos', 'Times New Roman';
font-size: 22px;
margin-top: 0px;
}
.head-bg{
width: 100%;
height: 50px;
background: url(../images/nadpis2_bg.jpg);
background-size:100% 100%;
background-attachment: fixed;
}
.flags{
margin-top: -25px;
padding-right: 35px;
}
.flags img{
width: 35%;
}
.container{
max-width: 760px;
}
.content{
padding: 15px;
}
.height{
height: 50px;
background-color: transparent;
}
/* Always float the navbar header */
.navbar-header {
float: left;
}
/* Undo the collapsing navbar */
.navbar-collapse {
display: block !important;
height: auto !important;
padding-bottom: 0;
overflow: visible !important;
visibility: visible !important;
}
.navbar-toggle {
display: none;
}
.navbar-collapse {
border-top: 0;
}
/* Always apply the floated nav */
.navbar-nav {
background-color: #000;
float: none;
display: inline-block;
}
.navbar-nav > li {
float: left;
}
.navbar-default {
background-color: transparent;
border-color: transparent;
border-top-color: white;
}
.navbar-default .navbar-nav > li > a {
padding-left: 20px;
padding-right: 20px;
padding-top: 3px;
padding-bottom: 3px;
color: white;
font-size: 12px;
}
/* Redeclare since we override the float above */
.navbar-nav.navbar-right {
float: right;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="head-bg">
<div class="container">
<div class="pull-right flags hidden-xs">
<a><img src="/images/bg_ico.png" alt="BG"></a>
</div>
<div class="height"></div>
<nav class="navbar navbar-default " role="navigation">
<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>
</div>
<div class="row collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav np">
<li class="nol">ЗА НАС</li>
<li>СТУДИО</li>
<li>ГАЛЕРИЯ</li>
<li>НОВИНИ</li>
<li>Е-МАГАЗИН</li>
<li class="nor">КОНТАКТИ</li>
</ul>
</div>
</nav>
<div class="pull-right flags visible-xs">
<a><img src="/images/bg_ico.png" alt="BG"></a>
</div>
Here is a photo of what it looks like now:
And here is a photo of what I would like it to be:
The solution was to apply style to the ul inside the navbar-collapse div. Here is the css.
.navbar-collapse > ul {
width: 100%;
margin: 0 auto !important;
}
Here is the fixed example:
#media screen
and (min-width: 320px)
and (max-width: 767px)
and (orientation: landscape) {
body{
margin: 0 auto;
background-image: url(../images/background_vm.jpg);
/*background-repeat:no-repeat;*/
background-attachment: fixed;
background-size:100% auto;
font-family: 'Tinos', 'Times New Roman';
font-size: 22px;
margin-top: 0px;
}
.head-bg{
width: 100%;
height: 50px;
background: url(../images/nadpis2_bg.jpg);
background-size:100% 100%;
background-attachment: fixed;
}
.flags{
margin-top: -25px;
padding-right: 35px;
}
.flags img{
width: 35%;
}
.container{
max-width: 760px;
}
.content{
padding: 15px;
}
.height{
height: 50px;
background-color: transparent;
}
/* Always float the navbar header */
.navbar-header {
float: left;
}
/* Undo the collapsing navbar */
.navbar-collapse {
display: block !important;
height: auto !important;
padding-bottom: 0;
overflow: visible !important;
visibility: visible !important;
}
.navbar-collapse > ul {
width: 100%;
margin: 0 auto !important;
}
.navbar-toggle {
display: none;
}
.navbar-collapse {
border-top: 0;
}
/* Always apply the floated nav */
.navbar-nav {
background-color: #000;
float: none;
display: inline-block;
}
.navbar-nav > li {
float: left;
}
.navbar-default {
background-color: transparent;
border-color: transparent;
border-top-color: white;
}
.navbar-default .navbar-nav > li > a {
padding-left: 20px;
padding-right: 20px;
padding-top: 3px;
padding-bottom: 3px;
color: white;
font-size: 12px;
}
/* Redeclare since we override the float above */
.navbar-nav.navbar-right {
float: right;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="head-bg">
<div class="container">
<div class="pull-right flags hidden-xs">
<a><img src="/images/bg_ico.png" alt="BG"></a>
</div>
<div class="height"></div>
<nav class="navbar navbar-default " role="navigation">
<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>
</div>
<div class="row collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav np">
<li class="nol">ЗА НАС</li>
<li>СТУДИО</li>
<li>ГАЛЕРИЯ</li>
<li>НОВИНИ</li>
<li>Е-МАГАЗИН</li>
<li class="nor">КОНТАКТИ</li>
</ul>
</div>
</nav>
<div class="pull-right flags visible-xs">
<a><img src="/images/bg_ico.png" alt="BG"></a>
</div>