So I've made a typical Bootstrap navbar and it works well on Desktop sizes. By default, when I added my logo wrapped with the navbar-brand class as in their documentation example, the logo overhangs off the navbar. I solved this problem by adding padding to the links themselves. This works fine until I resize the browser to act like a mobile device. When it collapses, the navbar's height decreases to fit the toggle switch and the logo again overhangs. How to I fix this? Did I go about making the height of the navbar the right way by adding padding? Or should I make it a fixed height by specifically assigning it?
The logo is 55px tall by 128px wide.
Here's my HTML:
<nav id="LC-navbar" class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div id="LC-navbar-header" class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#LC-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a id="LC-navbar-brand" class="navbar-brand img-responsive" href="../">
<img class="img-responsive" src="../assets/img/logo-horizontal.png">
</a>
</div>
<div id="LC-navbar-collapse" class="collapse navbar-collapse">
<ul id="LC-navbar-links" class="nav navbar-nav navbar-right">
<li>Home</li>
<li class="active">Shop</li>
<li>Our Team</li>
<li>About Us</li>
<li>Contact Us</li>
</ul>
</div>
</div>
</nav>
And CSS:
#LC-navbar {
background-color: #202020;
border: none;
}
.navbar-brand {
padding-left: 30px;
}
#LC-navbar-links {
padding-right: 20px;
}
#LC-navbar-links li {
padding: 16px 10px;
}
#LC-navbar-links a {
font-size: 16px;
font-weight: 300;
text-transform: uppercase;
color: #c0c0c0;
-webkit-transition: color 0.25s;
-moz-transition: color 0.25s;
-o-transition: color 0.25s;
transition: color 0.25s;
}
#LC-navbar-links a:hover {
color: #BE1E2D;
}
#LC-navbar-links .active > a {
color: #BE1E2D;
background: none;
}
#LC-navbar-links .active > a:hover {
color: #BE1E2D;
background: none;
}
How would I go about changing styles to the navbar when it's collapsed? Obviously to change the overhang problem but also if say I want it to have a different background color when collapsed vs when open?
The toggle menu appears lesser than the width of 768px, so use the max-width: 768px media-query.
#media (max-width: 768px) {
.navbar-brand {
height: 80px; // Logo will not overhang
}
#LC-navbar {
background-color: #ccc; // Change background color
}
.navbar-toggle {
margin-top: 25px; // Adjust toggle position
}
}
Related
The way I have my navbar set up right now is when I am scrolled to the top, the navbar background is transparent, and as soon as I start scrolling down, the navbar background appears as black. The only problem I am having right now is when I am on mobile size and I am scrolled to the top, when I click the navbar toggle dropdown button, the background on the drop down menu is transparents since I am scrolled all the way up, but I'd like to find a way to have the black background appear when the dropdown menu is active when scrolled all the way to the top of the browser.
HTML
<nav class="navbar navbar-default top-of-page">
<div class="container">
<!-- 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" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src='/CMS_Static/Uploads/313864614C6F6F/fv-logo-3.gif' align="left"/></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul id="navLinks" class="nav navbar-nav">
<li>Home</li>
<li>Services</li>
<li>Stock Photography/ Footage</li>
<li>Contact</li>
</ul>
</div>
</div>
</nav>
Java Script
<script> $(window).on("scroll", function() {
var scrollPos = $(window).scrollTop();
if (scrollPos <= 0) {
$('.navbar-default').addClass('top-of-page');
} else {
$('.navbar-default').removeClass('top-of-page');
}
});
</script>
CSS
.top-of-page {
background-color: transparent;
}
.navbar-default {
background-color: black;
background: rgba(0,0,0,.85);
min-height: 90px;
position: fixed;
border-radius: 5px;
border: none;
width: 100%;
z-index: 1;
}
#navLinks {
padding-left: 20px;
}
#navLinks li {
padding-top: 20px;
padding-right: 10px;
}
#navLinks li a {
color: white;
font-size: 1.1em;
font-weight: 700;
}
#navLinks li a:hover {
color: #a6b1c4;
}
.navbar-brand img {
height: 35px;
}
Write media query. when device width is less than something say 700px for phone give background color to ... top-of-page class.
code ...
#media only screen and (max-width: 500px) {
.top-of-page{
background-color: #000;
}
}
I have a navbar with a couple of links on the left side and social media buttons on the right. The problem is that when i shrink the window, the links and buttons do not collapse into pills soon enough. Instead, the social media buttons from the right side go under the links on the left side. And then when the window is too narrow to fit the links, the pills appear.
How can I edit this so the navbar collapses at the right position?
Any help is much appreciated:)
Here is my code:
<nav class="navbar navbar-default navbar-fixed-top">
<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="#">WebsiteName</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active">Link1</li>
<li>Link2</li>
<li>Link3</li>
<li>Link4</li>
</ul>
<ul class="nav navbar-nav navbar-right nav-pills social-icons icon-circle icon-rotate">
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-instagram"></i></li>
<li><i class="fa fa-twitter"></i></li>
</ul>
</div>
</div>
</nav>
Where you see 1000px, add your own width you want.
#media (max-width: 1000px) {
.navbar-header {
float: none;
}
.navbar-left,.navbar-right {
float: none !important;
}
.navbar-toggle {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
.navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
float: none!important;
margin-top: 7.5px;
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.collapse.in{
display:block !important;
}
}
you can create a class that , according to from the screen size , determines the width or more of the navbar .
#media ( max-width : 767px ) {
.widthNavbar {
width : 700px;
}
}
or you can put the class is activated between two values :
#media ( min-width : 768px ) and ( max-width : 979px ) {
.widthNavbar {
width : 700px;
}
}
I've done a crap ton of research into how I can accomplish this, but I can't find anything solid or anything that I can properly understand.
I want to override the Bootstrap Dropdown hover color. Not the Dropdown menu, the actual Dropdown button itself. By default, the text color is white, and when you hover over it, it's some sort of blue-green color. I want to make the blue-green color to white as well.
Does anyone have any idea how I can go about doing this?
Here's my current code incase you need it:
CSS:
#media {
ul.nav li.dropdown:hover > ul.dropdown-menu {
display: block;
}
.navbar-custom {
color: #262626;
background-color: #262626;
}
.navbar-default {
color: #262626;
background-color: #262626;
border-top: 4px solid red;
}
.navbar-default .navbar-brand:hover {
color: white;
}
.dropdown:hover {
color: white;
}
}
body {
background-color: black;
}
#navbar {
width: 100%;
}
HTML:
<div class="navbar navbar-default navbar-custom navbar-fixed-top">
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav" id="dropdowns">
<a class="navbar-brand" id="brand">Traders: </a>
<li class="dropdown">
General <span class="caret"></span>
<ul class="dropdown-menu pull-left" role="menu">
<li>Medical</li>
<li>Utility</li>
</ul>
</li>
</ul>
</div>
</div>
Sorry if I left something out or don't make much sense, currently on some powerful pain meds. This helps me get my mind off the pain.
You can try including the !important to the style:
color: white !important;
this is done to override the default styles bootstrap establishes for the elements.
I am trying to decrease the height of the Bootstrap 3.1.1's navbar without using the less version of it. I have tried several ways of doing this by reading around on different sites, and none of them are decreasing the CSS's .navbar height.
I have managed to fix the padding on the .navbar-nav > li > a.
My HTML:
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">QuadCMS</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>Help</li>
</ul>
</div>
</div>
</div>
My CSS which overrides the Bootstrap to try to fix the navbar.
.navbar {
height: 25px !important;
}
.navbar-nav > li > a {
padding-top: 5px !important;
padding-bottom: 5px !important;
}
My main issue is with the actual height of the navbar, not the padding now. The padding of the navigation links are fixed and working at the small size. I have also tried changing the .navbar to .navbar-nav, and .navbar-fixed-top respectfully and nothing has worked yet.
Do I need to call a different CSS Class then the ones I have tried, or do I need to call two of the ones I have already tried to get the effect needed?
Here is the default .navbar styling:
.navbar {
position: relative;
min-height: 50px;
margin-bottom: 20px;
border: 1px solid transparent;
}
You need to overwrite the min-height property. You can use the value inherit.
Example Here
.navbar {
height: 30px;
min-height: inherit;
}
.navbar-nav > li > a {
padding-top: 5px;
padding-bottom: 5px;
}
.navbar-brand {
padding:5px 0 0 0;
}
I have a simple top-fixed nav using Bootstrap 3.0 which utilizes the submenu feature. I'm attempting to have my submenu take up the full width of the container, not just the width of the combined submenu elements. The problem appears to be coming from the ul.dropdown-menu code in which the width is set to ~160px; Not only that, but it refuses to extend left, past the dropdown menu tab. This is a problem because my collapse-nav is set to sit on the right side. Oy.
Below is a fiddle of my current solution.
FIDDLE FIDDLE, YA'LL
HTML:
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<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="index.html"></a>
</div>
<div class="navbar-collapse collapse pull-right">
<ul class="nav navbar-nav">
<li class="dropdown active">
Films <b class="caret"></b>
<ul class="dropdown-menu">
<div class="container">
<ul class="list-inline">
<li class="placeholder" id="pause"></li>
<li class="placeholder" id="hiccup"></li>
<li class="placeholder"></li>
<li class="placeholder"></li>
<li class="placeholder"></li>
<li class="placeholder"></li>
</ul>
</div>
</ul>
</li>
<li>About</li>
<li>Contact</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
CSS (sorry it's so specific, I'm using SASS):
.navbar.navbar-default.navbar-fixed-top {
background-color: #454545;
border: none;
}
.navbar.navbar-default.navbar-fixed-top .container .navbar-collapse.collapse.pull-right ul.nav.navbar-nav li.active a, .navbar.navbar-default.navbar-fixed-top .container .navbar-collapse.collapse.pull-right ul.nav.navbar-nav li a:hover {
color: #ffcc00;
background-color: #454545;
height: inherit;
}
.navbar.navbar-default.navbar-fixed-top .container .navbar-collapse.collapse.pull-right ul.nav.navbar-nav li.dropdown.active.open ul.dropdown-menu {
list-style-type: none;
width: 100%;
background-color: white;
}
.navbar.navbar-default.navbar-fixed-top .container .navbar-collapse.collapse.pull-right ul.nav.navbar-nav li.dropdown.active.open ul.dropdown-menu .container {
background-color: white;
}
.navbar.navbar-default.navbar-fixed-top .container .navbar-collapse.collapse.pull-right ul.nav.navbar-nav li.dropdown.active.open ul.dropdown-menu .container ul.list-inline {
list-style-type: none;
width: 100%;
}
.navbar.navbar-default.navbar-fixed-top .container .navbar-collapse.collapse.pull-right ul.nav.navbar-nav li.dropdown.active.open ul.dropdown-menu .container ul.list-inline li.placeholder {
margin: 0 20px;
height: 100px;
width: 70px;
background-color: #999999;
}
So far the closest solution I've come across is adding a container within the dropdown menu, however I'm still unable to extend the dropdown menu beyond it's ~160px width.
The general goal is to have a full-width dropdown menu. Currently not worried about what it looks like on mobile devices.
Thanks
I use Yamm3 to do this, it's quite easy to integrate and allows you to specify a full width for your mega menu.
http://geedmo.github.io/yamm3/