I want to center the logo. I was able to center it by defining the padding and stuff but the problem is that the logo moves when I try to view it on a different monitor/resolution.
Here's the Code:
/* Navigation */
.navbar {-moz-border-radius: 0;-webkit-border-radius: 0;border-radius: 0;margin-bottom: 0;}
.navbar .container {text-align: center; position: center; background-color: #fff; right:55px;}
.navbar-default {-moz-transition: all 0.3s ease-out;-o-transition: all 0.3s ease-out;-webkit-transition: all 0.3s ease-out;transition: all 0.3s ease-out;width: 100%;border: none;border-bottom: 0px solid #e7e7e7;background-color: #fff; }
.navbar-default .navbar-nav > li > a {color: #000;font-weight: normal;font-size: 15px; display: inline-block; padding-right: 23px; padding-left: 23px}
.navbar-default .navbar-nav > li > a:hover {background-color: transparent;color: #005FA6;}
.navbar-default .navbar-nav > .open > a,.navbar-default .navbar-nav > .open > a:hover,.navbar-default .navbar-nav > .open > a:focus {background-color: transparent;color: #005FA6;}
.navbar-default .navbar-nav .active > a,.navbar-default .navbar-nav .active > a:hover,.navbar-default .navbar-nav .active > a:focus {color: #005FA6;background-color: transparent;}
.navbar-default .navbar-toggle {margin: 10px 0 0 15px;}
.navbar-default .navbar-toggle,.navbar-default .navbar-toggle:hover,.navbar-default .navbar-toggle:focus {border: none;background: #f3f3f3;}
.navbar-default .navbar-toggle i {font-size: 31px;}
.navbar-default .navbar-collapse {float: right; border-top: none;padding-left: 0;padding-right: 0;}
.navbar-brand>img {padding: 5px; align: center;}
<nav class="navbar navbar-default">
<div class="container">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-navbar-collapse">
<span class="sr-only">Toggle Navigation</span>
<i class="fa fa-bars"></i>
</button>
<a href="index.php" class="navbar-brand">
<img src="img/corelogo.png" alt="" height="150" width="150">
</a>
</div>
</nav>
Set your logo <img> tag as display:block. Then give it a left and right margin of auto.
Example below:
/* Navigation */
.navbar {
-moz-border-radius: 0;
-webkit-border-radius: 0;
border-radius: 0;
margin-bottom: 0;
}
.navbar .container {
text-align: center;
position: center;
background-color: #fff;
right: 55px;
}
.navbar-default {
-moz-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
-webkit-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
width: 100%;
border: none;
border-bottom: 0px solid #e7e7e7;
background-color: #fff;
}
.navbar-default .navbar-nav>li>a {
color: #000;
font-weight: normal;
font-size: 15px;
display: inline-block;
padding-right: 23px;
padding-left: 23px
}
.navbar-default .navbar-nav>li>a:hover {
background-color: transparent;
color: #005FA6;
}
.navbar-default .navbar-nav>.open>a,
.navbar-default .navbar-nav>.open>a:hover,
.navbar-default .navbar-nav>.open>a:focus {
background-color: transparent;
color: #005FA6;
}
.navbar-default .navbar-nav .active>a,
.navbar-default .navbar-nav .active>a:hover,
.navbar-default .navbar-nav .active>a:focus {
color: #005FA6;
background-color: transparent;
}
.navbar-default .navbar-toggle {
margin: 10px 0 0 0;
}
.navbar-default .navbar-toggle,
.navbar-default .navbar-toggle:hover,
.navbar-default .navbar-toggle:focus {
border: none;
background: #f3f3f3;
}
.navbar-default .navbar-toggle i {
font-size: 31px;
}
.navbar-default .navbar-collapse {
float: right;
border-top: none;
padding-left: 0;
padding-right: 0;
}
.navbar-brand img {
border:1px solid black;
width:150px;
height:150px;
display:block;
margin: 15px auto 0px auto;
}
<nav class="navbar navbar-default">
<div class="container">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-navbar-collapse">
<span class="sr-only">Toggle Navigation</span>
<i class="fa fa-bars"></i>
</button>
<a href="index.php" class="navbar-brand">
<img src="img/corelogo.png" alt="" height="150" width="150">
</a>
</div>
</nav>
You just need make your image a block element by adding display: block; and then adding an auto margin with margin: 0 auto;
Here is your code: .navbar-brand > img { display: block; margin: 0 auto;}
<style>
.navbar {-moz-border-radius: 0;-webkit-border-radius: 0;border-radius: 0;margin-bottom: 0;}
.navbar .container {text-align: center; position: center; background-color: #fff; right:55px;}
.navbar-default {-moz-transition: all 0.3s ease-out;-o-transition: all 0.3s ease-out;-webkit-transition: all 0.3s ease-out;transition: all 0.3s ease-out;width: 100%;border: none;border-bottom: 0px solid #e7e7e7;background-color: #fff; }
.navbar-default .navbar-nav > li > a {color: #000;font-weight: normal;font-size: 15px; display: inline-block; padding-right: 23px; padding-left: 23px}
.navbar-default .navbar-nav > li > a:hover {background-color: transparent;color: #005FA6;}
.navbar-default .navbar-nav > .open > a,.navbar-default .navbar-nav > .open > a:hover,.navbar-default .navbar-nav > .open > a:focus {background-color: transparent;color: #005FA6;}
.navbar-default .navbar-nav .active > a,.navbar-default .navbar-nav .active > a:hover,.navbar-default .navbar-nav .active > a:focus {color: #005FA6;background-color: transparent;}
.navbar-default .navbar-toggle {margin: 10px 0 0;}
.navbar-default .navbar-toggle,.navbar-default .navbar-toggle:hover,.navbar-default .navbar-toggle:focus {border: none;background: #f3f3f3;}
.navbar-default .navbar-toggle i {font-size: 31px;}
.navbar-default .navbar-collapse {float: right; border-top: none;padding-left: 0;padding-right: 0;}
.navbar-brand > img { display: block; margin: 0 auto;}
</style>
<nav class="navbar navbar-default">
<div class="container">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-navbar-collapse">
<span class="sr-only">Toggle Navigation</span>
<i class="fa fa-bars"></i>
</button>
<a href="index.php" class="navbar-brand">
<img class="my-image" src="img/corelogo.png" alt="" height="150" width="150">
</a>
</div>
</nav>
Related
As you can see in the code below, when I resize window size, the image doesn't scale with it. I don't want to make the image distort when I resize the window. I want to make it so the image center is always in the middle of the window. Like on the phone I don't need to see the blue and red parts of the image just the center logo in middle and according to so with window resize until its full screen with full hero image in view. How do I do this? I can't really find any documentation with bootstrap.
input{
border: none;
border-bottom: 2px solid white;
}
::placeholder {
color: white
}
input[type=text] {
width: 36%;
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
background-color: transparent;
color: white !important;
}
input[type=text]:focus {
width: 50%;
background-color: transparent;
color: white !important;
}
.bg-primary {
background-color: #000000 !important;
}
.custom-toggler .navbar-toggler-icon {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(255,255,255, 1)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E");
}
.navbar-nav .open .dropdown-menu {
color: white
}
.navbar {
background-color: #000000;
}
.navbar .navbar-brand {
color: #ffffff;
}
.navbar .navbar-brand:hover,
.navbar .navbar-brand:focus {
color: #ededed;
}
.navbar .navbar-text {
color: #ffffff;
}
.navbar .navbar-text a {
color: #ededed;
}
.navbar .navbar-text a:hover,
.navbar .navbar-text a:focus {
color: #ededed;
}
.navbar .navbar-nav .nav-link {
color: #ffffff;
border-radius: .25rem;
margin: 0 0.25em;
}
.navbar .navbar-nav .nav-link:not(.disabled):hover,
.navbar .navbar-nav .nav-link:not(.disabled):focus {
color: #ededed;
}
.navbar .navbar-nav .dropdown-menu {
background-color: #000000;
border-color: #000000;
}
.navbar .navbar-nav .dropdown-menu .dropdown-item {
color: #ffffff;
}
.navbar .navbar-nav .dropdown-menu .dropdown-item:hover,
.navbar .navbar-nav .dropdown-menu .dropdown-item:focus,
.navbar .navbar-nav .dropdown-menu .dropdown-item.active {
color: #ededed;
background-color: #000000;
}
.navbar .navbar-nav .dropdown-menu .dropdown-divider {
border-top-color: #000000;
}
.navbar .navbar-nav .nav-item.active .nav-link,
.navbar .navbar-nav .nav-item.active .nav-link:hover,
.navbar .navbar-nav .nav-item.active .nav-link:focus,
.navbar .navbar-nav .nav-item.show .nav-link,
.navbar .navbar-nav .nav-item.show .nav-link:hover,
.navbar .navbar-nav .nav-item.show .nav-link:focus {
color: #ededed;
background-color: #000000;
}
.navbar .navbar-toggle {
border-color: #000000;
}
.navbar .navbar-toggle:hover,
.navbar .navbar-toggle:focus {
background-color: #000000;
}
.navbar .navbar-toggle .navbar-toggler-icon {
color: #ffffff;
}
.navbar .navbar-collapse,
.navbar .navbar-form {
border-color: #ffffff;
}
.navbar .navbar-link {
color: #ffffff;
}
.navbar .navbar-link:hover {
color: #ededed;
}
#media (max-width: 575px) {
.navbar-expand-sm .navbar-nav .show .dropdown-menu .dropdown-item {
color: #ffffff;
}
.navbar-expand-sm .navbar-nav .show .dropdown-menu .dropdown-item:hover,
.navbar-expand-sm .navbar-nav .show .dropdown-menu .dropdown-item:focus {
color: #ededed;
}
.navbar-expand-sm .navbar-nav .show .dropdown-menu .dropdown-item.active {
color: #ededed;
background-color: #000000;
}
}
#media (max-width: 767px) {
.navbar-expand-md .navbar-nav .show .dropdown-menu .dropdown-item {
color: #ffffff;
}
.navbar-expand-md .navbar-nav .show .dropdown-menu .dropdown-item:hover,
.navbar-expand-md .navbar-nav .show .dropdown-menu .dropdown-item:focus {
color: #ededed;
}
.navbar-expand-md .navbar-nav .show .dropdown-menu .dropdown-item.active {
color: #ededed;
background-color: #000000;
}
}
#media (max-width: 991px) {
.navbar-expand-lg .navbar-nav .show .dropdown-menu .dropdown-item {
color: #ffffff;
}
.navbar-expand-lg .navbar-nav .show .dropdown-menu .dropdown-item:hover,
.navbar-expand-lg .navbar-nav .show .dropdown-menu .dropdown-item:focus {
color: #ededed;
}
.navbar-expand-lg .navbar-nav .show .dropdown-menu .dropdown-item.active {
color: #ededed;
background-color: #000000;
}
}
#media (max-width: 1199px) {
.navbar-expand-xl .navbar-nav .show .dropdown-menu .dropdown-item {
color: #ffffff;
}
.navbar-expand-xl .navbar-nav .show .dropdown-menu .dropdown-item:hover,
.navbar-expand-xl .navbar-nav .show .dropdown-menu .dropdown-item:focus {
color: #ededed;
}
.navbar-expand-xl .navbar-nav .show .dropdown-menu .dropdown-item.active {
color: #ededed;
background-color: #000000;
}
}
.navbar-expand .navbar-nav .show .dropdown-menu .dropdown-item {
color: #ffffff;
}
.navbar-expand .navbar-nav .show .dropdown-menu .dropdown-item:hover,
.navbar-expand .navbar-nav .show .dropdown-menu .dropdown-item:focus {
color: #ededed;
}
.navbar-expand .navbar-nav .show .dropdown-menu .dropdown-item.active {
color: #ededed;
background-color: #000000;
}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" href="styles.css">
<title>(Insert Name) Reviews)</title>
<link rel="icon" type="image/png" sizes="100x100" href="https://moundspet.com/wp-content/uploads/2017/03/Placeholder-1.png">
</head>
<body>
<nav class="navbar navbar-expand-lg">
<a class="navbar-brand" href="index.html"> <img alt="logo" src="https://moundspet.com/wp-content/uploads/2017/03/Placeholder-1.png" width="30" height="30"></a>
<input class="mr-auto" type="text" name="search" placeholder="Search...">
<button class="navbar-toggler custom-toggler" type="button" data-toggle="collapse" data-target="#collapse"
aria-controls="collapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collapse">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#">Sign Up</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Login</a>
</li>
</ul>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<img class="img-responsive" alt="background" src="https://i.imgur.com/I47YLUI.jpg" style="width:1536px;height:600px;">
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"
integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI"
crossorigin="anonymous"></script>
</body>
You can use img-fluid class on image tag that will scale the image as per devices and remove custom CSS on image
bootstrap - responsive-images
I found a code for the sticky navbar on this site, I copied the code and tried to run on my laravel blade file. Following is the complete code.output comes like
I copied the code in following way.
CSS
JS
HTML
please let me know what to do, I am beginner and trying to learn. Thank you
This code not working with Bootstrap 4. Use the correct CSS and JS link.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Unbenanntes Dokument</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.image {
background-color: #490D40;
background: url(https://sonorangirl.github.io/Earth-Quotes/img/google-earth-view-South-Iceland3.jpg) no-repeat center center;
background-size: cover;
height: 570px;
margin-top: -20px;
}
.image .heading {
color: white;
text-align: center;
padding-top: 200px;
}
.image p {
text-align: center;
padding: 20px 60px;
}
.image p .btn {
background-color: transparent;
color: white;
border: 1px solid white;
padding: 10px;
font-size: 1.2em;
}
.image p .btn:hover {
color: #C57ED3;
border-color: #C57ED3;
}
.navbar {
height: 80px;
background-color: transparent;
border: none;
color: white;
z-index: 100;
transition: background-color 1s ease 0s;
}
.navbar-default .navbar-brand {
margin-top: 10px;
color: white;
}
.navbar-default .navbar-brand:hover {
color: #C57ED3;
border: 1px solid #C57ED3;
}
.navbar-default .navbar-nav > li > a {
color: white !important;
margin: 10px 5px 5px 5px;
}
.navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:active, .navbar-default .navbar-nav > li > a:focus {
color: #C57ED3;
border: 1px solid #C57ED3;
}
.navbar-default .navbar-nav > li > a:visited {
color: #C57ED3;
text-decoration: none;
}
.navbar-default .navbar-nav > .active > a, .navbar-default .navbar-nav > .active > a:hover, .navbar-default .navbar-nav > .active > a:focus {
background-color: transparent;
color: #C57ED3;
}
.navbar-default .navbar-toggle {
border-color: #C57ED3;
}
.navbar-default .navbar-toggle:hover, .navbar-default .navbar-toggle:focus {
background-color: #490D40;
}
.navbar-default .navbar-toggle .icon-bar {
color: #C57ED3;
background-color: #C57ED3;
}
.navbar-default .navbar-collapse.collapse.in ul {
background-color: #490D40;
}
/* Solid class attached on scroll past first section */
.navbar.solid {
background-color: #490D40;
transition: background-color 1s ease 0s;
box-shadow: 0 0 4px grey;
}
.navbar.solid .navbar-brand {
color: #C57ED3;
transition: color 1s ease 0s;
}
.navbar.solid .navbar-nav > li > a {
color: #C57ED3 !important;
transition: color 1s ease 0s;
}
.about {
background-color: #C57ED3;
color: #490D40;
height: 600px;
text-align: center;
margin-top: -20px;
min-height: 200vh;
}
.about h2 {
padding-top: 220px;
}
.about p {
padding: 20px 80px;
}
</style>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<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" href="#">Transparent to Solid Nav</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li>About</li>
<li>Link</li>
<li>Another Link</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="image">
<h1 class="heading">Main Heading</h1>
<p><button class="btn btn-large">Big Button</button></p>
</div>
<div class="about">
<h2>Main Description</h2>
<p>Roll on the floor purring your whiskers off intrigued by the shower burrow under covers, and play time, rub face on everything, intently sniff hand, or pelt around the house and up and down stairs chasing phantoms. Attack feet. Damn that dog shake treat bag under the bed drink water out of the faucet for lick butt love to play with owner's hair tie. Swat at dog give attitude.</p>
</div>
</body>
<script>
$(document).ready(function() {
// Transition effect for navbar
$(window).scroll(function() {
// checks if window is scrolled more than 500px, adds/removes solid class
if($(this).scrollTop() > 500) {
$('.navbar').addClass('solid');
} else {
$('.navbar').removeClass('solid');
}
});
});
</script>
</html>
min-height: 200vh; by .about class is optional for testing.
i have been playing around with bootstrap to setup a navbar the way i would like it to be.
I am struggling as you might see in my code to have everything vertically centered properly in this menu. I have made some average fix by playing with the margin but i can't fix the button.
I am sure there is a simple solution with position:relative to have everything center but i can't find it.
http://codepen.io/anon/pen/yMGEZb
Thanks for your help !
updated codepen
Just add the button inside navbar-right li.no need to modify your css.
example snippet
.navbar-default .navbar-header .navbar-brand {
font-family: 'Catamaran', 'Helvetica', 'Arial', 'sans-serif';
font-weight: 200;
letter-spacing: 1px;
color: #fdcc52;
}
.navbar-default .navbar-header .navbar-brand:hover,
.navbar-default .navbar-header .navbar-brand:focus {
color: #fcbd20;
}
.navbar-default .navbar-header .navbar-toggle {
font-size: 12px;
color: #222222;
padding: 8px 10px;
}
.navbar-default .nav > li > a {
font-family: Montserrat;
font-weight:300;
font-style:normal;
text-transform: uppercase;
letter-spacing: 2px;
font-size: 13px;
color: #121212;
}
/*#media (min-width: 768px)
.button-nav {
display: inline-block;
z-index: 101;
}*/
.button-nav {
position: relative;
bottom: 50%;
background-color: transparent;
font-family: Montserrat;
font-weight: 300;
font-style:normal;
letter-spacing:2px;
font-size: 13px;
color: #121212;
text-transform: uppercase;
border: 1px solid #121212;
padding: 18px 40px;
transition: color .4s cubic-bezier(.694,.0482,.335,1),background-color .4s cubic-bezier(.694,.0482,.335,1),border .4s cubic-bezier(.694,.0482,.335,1);
cursor:pointer;
text-align:center;
text-rendering: optimizeLegibility;
}
.button-nav:hover {
background-color: #1c1c1c;
font-family: Montserrat;
font-weight: 300;
font-style:normal;
letter-spacing:2px;
font-size: 13px;
color: white;
text-transform: uppercase;
border: 1px solid #1c1c1c;
padding: 18px 40px;
transition: color .4s cubic-bezier(.694,.0482,.335,1),background-color .4s cubic-bezier(.694,.0482,.335,1),border .4s cubic-bezier(.694,.0482,.335,1);
cursor:pointer;
text-align:center;
text-rendering: optimizeLegibility;
}
.navbar-default .nav > li > a,
.navbar-default .nav > li > a:focus {
color: #121212;
}
.navbar-default .nav > li > a:hover,
.navbar-default .nav > li > a:focus:hover {
color: #fdcc52;
}
.navbar-default .nav > li.active > a,
.navbar-default .nav > li.active > a:focus {
color: #fdcc52 !important;
background-color: transparent;
}
.navbar-default .nav > li.active > a:hover,
.navbar-default .nav > li.active > a:focus:hover {
background-color: transparent;
}
#media (min-width: 768px) {
.navbar-default {
background-color: transparent;
border-color: transparent;
}
.navbar-default .navbar-header .navbar-brand {
color: rgba(34, 34, 34, 0.1);
}
.navbar-default .navbar-header .navbar-brand:hover,
.navbar-default .navbar-header .navbar-brand:focus {
color: white;
}
.navbar-default .nav > li > a,
.navbar-default .nav > li > a:focus {
color: #121212;
}
.navbar-default .nav > li > a:hover,
.navbar-default .nav > li > a:focus:hover {
color: white;
}
.navbar-default.affix {
background-color: white;
border-color: rgba(34, 34, 34, 0.1);
}
.navbar-default.affix .navbar-header .navbar-brand {
color: #222222;
}
.navbar-default.affix .navbar-header .navbar-brand:hover,
.navbar-default.affix .navbar-header .navbar-brand:focus {
color: #fdcc52;
}
.navbar-default.affix .nav > li > a,
.navbar-default.affix .nav > li > a:focus {
color: #222222;
}
.navbar-default.affix .nav > li > a:hover,
.navbar-default.affix .nav > li > a:focus:hover {
color: #fdcc52;
}
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav id="mainNav" class="navbar navbar-default navbar-fixed-top">
<div class="container" style="height:80px;">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span> Menu <i class="fa fa-bars"></i>
</button>
<a class="navbar-brand page-scroll" href="#page-top">
<img src="http://svgshare.com/i/17J.svg" width="220" height="50" alt="">
</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right" style="margin-top:20px;">
<li>
<a class="page-scroll" href="#download">Download</a>
</li>
<li>
<a class="page-scroll" href="#features">Features</a>
</li>
<li>
<a class="page-scroll" href="#contact">Contact</a>
</li>
<li><button class="button-nav pull-right">Get started</button></li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
I'm trying to remove the gap between the Navbar and the Carousel.
However I can't for the life of me work out which element is causing the gap and how to fix it.
/* CSS used here will be applied after bootstrap.css */
.navbar {
margin: 0; /*add this*/
padding: 0px;
}
.navbar-default {
background-color: #ffffff;
}
/* title */
.navbar-default .navbar-brand {
color: #000000;
}
.navbar-default .navbar-brand:hover,
.navbar-default .navbar-brand:focus {
color: #808080;
}
/* link */
.navbar-default .navbar-nav > li > a {
color: #000000;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: #808080;
}
/* active link */
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
color: #ffffff;
background-color: #000000;
}
.navbar-default .navbar-nav > .open > a,
.navbar-default .navbar-nav > .open > a:hover,
.navbar-default .navbar-nav > .open > a:focus {
color: #555;
background-color: #ff0000;
}
/* caret */
.navbar-default .navbar-nav > .dropdown > a .caret {
border-top-color: #777;
border-bottom-color: #777;
}
.navbar-default .navbar-nav > .dropdown > a:hover .caret,
.navbar-default .navbar-nav > .dropdown > a:focus .caret {
border-top-color: #333;
border-bottom-color: #333;
}
.navbar-default .navbar-nav > .open > a .caret,
.navbar-default .navbar-nav > .open > a:hover .caret,
.navbar-default .navbar-nav > .open > a:focus .caret {
border-top-color: #555;
border-bottom-color: #555;
}
/* mobile version */
.navbar-default .navbar-toggle {
border-color: #DDD;
}
.navbar-default .navbar-toggle:hover,
.navbar-default .navbar-toggle:focus {
background-color: #DDD;
}
.navbar-default .navbar-toggle .icon-bar {
background-color: #CCC;
}
#media (max-width: 767px) {
.navbar-default .navbar-nav .open .dropdown-menu > li > a {
color: #777;
}
.navbar-default .navbar-nav .open .dropdown-menu > li > a:hover,
.navbar-default .navbar-nav .open .dropdown-menu > li > a:focus {
color: #333;
}
}
.container {
padding-top: 0px !important;
padding-bottom: 0px !important;
margin-top: 0px !important;
margin-bottom: 0px !important;
}
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">Progression</a>
<a 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>
</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>Physio</li>
<li>Massage</li>
<li>Beauty</li>
<li>First Aid</li>
</ul>
</div>
</div>
</nav>
<!-- Carousel -->
<div class="container">
<div class="row">
<div class="col-sm-12>
<div id=" my-slider"="" data-ride="carousel">
<!-- indicators dot nav -->
<!-- wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="https://lh5.googleusercontent.com/-WHXl1TAoHoQ/VsW7_mHWeQI/AAAAAAAAAEQ/nzQm8w62c3s/w1310-h524-no/Progression_Massage_Budha.png" alt="Physio Massage Val d'Isere">
<div class="carousel-caption">
<h2>Massage</h2>
<h4>Relaxation to Deep Tissue</h4>
</div><!-- end carousel caption -->
</div>
<div class="item">
<img src="https://lh4.googleusercontent.com/-lj7DIStRI8M/VthrRPFcQFI/AAAAAAAAAFY/2ynRLjTZTnI/w1310-h524-no/Progression_Beauty_Therapies.png" alt="Beauty Treatments Nails Facials & Waxing Val d'Isere">
<div class="carousel-caption">
<h2>Beauty</h2>
<h4>Nails - Facials - Waxing</h4>
</div>
</div>
<div class="item">
<img src="https://lh4.googleusercontent.com/-aCIY16PFylg/VsW6L-YwpqI/AAAAAAAAADA/wSTG1QlJLqY/w1310-h524-no/Progression_Val_dIsere.png" alt="Physiotherapy Assesment Treatment Rehab Val d'Isere">
<div class="carousel-caption">
<h2>Physiotherapy</h2>
<h4>Assesment Treatment Rehab</h4>
</div>
</div>
</div>
</div>
</div>
</div>
http://www.bootply.com/jbTugk4aPV
Actually that's not a 1 pixel gap it a border in css names navbar.less line no. 15.
Here is your css
.navbar {
position: relative;
min-height: 50px;
margin-bottom: 20px;
border: 1px solid transparent;
}
Remember its your css file code not mile the border in it creating that gap you can override this by typing another css in your file.
.navbar{
border:none!important;
}
Or you can simply set the border-width to 0px in
.navbar-static-top {
z-index: 1000;
border-width: 0px;
}
to remove the 1px white navbar border.
I am trying to add a border around my drop down menu which appears for mobile sizes. Thought it would be to control through .navbar-collapse but it doesn't seem to be working. Any ideas?
Sample pic of mobile size:
My code is as follows:
<nav class="navbar navbar-default navbar-fixed-top">
<div class="navbar-header">
<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>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">I am fouridine
</li>
<li>design
</li>
<li>animation
</li>
<li>other art
</li>
<li>contact
</li>
</ul>
</ul>
</div>
<!--/.nav-collapse -->
</nav>
CSS for nav is as such:
#media (min-width: 768px) {
.navbar {
display: none;
}
}
.navbar {
min-height:0;
}
.navbar-nav {
margin:0;
}
.navbar-default {
background-color:#47c4c0;
border:0;
height:30px;
font-size: 16px;
}
.container > .navbar-header, .container-fluid > .navbar-header, .container > .navbar-collapse, .container-fluid > .navbar-collapse {
margin:0;
border:0 30px 30px 30px;
}
.nav > li > a {
padding: 5px 20px 5px 20px;
}
.navbar-default .navbar-nav > li > a {
color: #47c4c0;
}
.navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus {
color: #666666;
}
.navbar-default .navbar-nav > .active > a, .navbar-default .navbar-nav > .active > a:hover, .navbar-default .navbar-nav > .active > a:focus {
color: white;
background-color: #47c4c0;
}
.navbar-default .navbar-collapse, .navbar-default .navbar-form {
border:0;
}
.navbar-collapse {
padding:0;
background:white;
border-style:solid;
border-color:#47c4c;
border:0 30px 30px 30px;
}
.navbar-toggle {
padding: 8px;
margin: 0;
border:0;
border-radius: 0;
}
.navbar-toggle .icon-bar {
width: 15px;
}
.navbar-default .navbar-toggle .icon-bar {
background-color: white;
}
.navbar-default .navbar-toggle:hover .icon-bar, .navbar-default .navbar-toggle:focus .icon-bar {
background-color: #47c4c0;
}
.navbar-default .navbar-toggle:hover, .navbar-default .navbar-toggle:focus {
background-color: white;
}
You can apply this to the navbar-nav class. Also see on MDN: border-width
#media (max-width: 767px) {
.navbar.navbar-default .navbar-nav {
background-color: white;
border: none;
margin-top: 0px;
border: solid #47c4c0;
border-width: 0 30px 30px;
}
}
See working Snippet.
#media (min-width: 768px) {
.navbar.navbar-default {
display: none;
}
}
.navbar.navbar-default {
min-height: 0;
background-color: #fff;
border: 0;
height: 30px;
font-size: 16px;
}
.navbar.navbar-default .navbar-nav > li > a {
padding: 5px 20px;
color: #47c4c0;
}
.navbar.navbar-default .navbar-nav > li > a:hover,
.navbar.navbar-default .navbar-nav > li > a:focus {
color: #666666;
}
.navbar.navbar-default .navbar-nav > .active > a,
.navbar.navbar-default .navbar-nav > .active > a:hover,
.navbar.navbar-default .navbar-nav > .active > a:focus {
color: white;
background-color: #47c4c0;
}
.navbar.navbar-default .navbar-collapse,
.navbar.navbar-default .navbar-form {
border: none;
}
#media (max-width: 767px) {
.navbar.navbar-default {
background-color: #47c4c0;
}
.navbar.navbar-default .navbar-toggle {
padding: 8px;
margin: 0;
border: 0;
border-radius: 0;
}
.navbar.navbar-default .navbar-toggle .icon-bar {
width: 15px;
background-color: white;
}
.navbar.navbar-default .navbar-toggle:hover .icon-bar,
.navbar.navbar-default .navbar-toggle:focus .icon-bar {
background-color: #47c4c0;
}
.navbar.navbar-default .navbar-toggle:hover,
.navbar.navbar-default .navbar-toggle:focus {
background-color: white;
}
.navbar.navbar-default .navbar-nav {
background-color: white;
border: none;
margin-top: 0px;
border: solid #47c4c0;
border-width: 0 30px 30px;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default navbar-fixed-top">
<div class="navbar-header">
<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>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">I am fouridine
</li>
<li>design
</li>
<li>animation
</li>
<li>other art
</li>
<li>contact
</li>
</ul>
</ul>
</div>
</nav>
border:0 30px 30px 30px solid black; // or whatever color you want
solid indicates the type of border, could also be dotted|dashed|solid|double|groove|ridge
and just pick the color you want
http://www.w3schools.com/cssref/pr_border-style.asp