I come to you because I'm pulling my hair out of my head on a design issue with bootstrap navbars.
I did a fixed top navbar with differents menu, one on the right and one on the left.
My CSS code turns the background of my links to the grey when the user hover them. But I notice that my menu items don't have the same height so when my pointer hover the smaller item, the new color doesn't fill the full height of the header bar.
This is some screenshots to help you :
And there is the code of my header bar :
<div class="container-fluid header-bar">
<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">Admin Page</a>
</div>
<!-- /.navbar-header -->
<ul class="nav navbar-nav navbar-left">
<li>
<a href class=" profile_image" >
<img src="../../../images/user.png" class="img-circle" alt="profile-pic"> {{vm.account.name}}
</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown" uib-dropdown="">
<a href class="dropdown-toggle lang_selector" uib-dropdown-toggle="">
<span class="flag-sm flag-sm-{{vm.defaultLang.flag}}"></span><span class="lang_desc">{{vm.defaultLang.text}}</span> <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu" uib-dropdown-menu="">
<li ng-repeat="lang in vm.langs"><a href class="lang_selector" ng-click="vm.defaultLang = lang"><span class="flag-sm flag-sm-{{lang.flag}}"></span><span class="lang_desc">{{lang.text}}</span></a></li>
</ul>
</li>
<li>
<a href="" ng-click="vm.logout()">
<md-icon class="li-icon-black material-icons" aria-label="logout">exit_to_app</md-icon>
</a>
</li>
</ul>
</div>
And there is the CSS code :
.smsmode-nav .navbar-header {
width: 250px;
}
.lang_selector > span {
vertical-align: middle;
}
.lang_desc {
margin-left: 8px
}
.navbar-nav > li > a.profile_image {
padding-top: 10px;
padding-bottom: 10px;
}
.profile_image > img {
width: 30px;
}
I know there is a story of padding but I try everything and I can't fix it. I'm desperated ! So I need your help please !
hi remove this css i hope you got your solutions
.lang_selector > span {
vertical-align: middle;
}
Related
I know similar questions have been asked, however after a lot of solution searching, none of them are working for me.
I am attempting to style (mostly concerned with font, color, and hover) the links in my Navbar.
html:
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">FLO Home</a>
</div>
<div class="collapse navbar-collapse nav-links" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
About
</li>
<li>
Products
</li>
<li>
Contact
</li>
</ul>
</div>
</div>
</nav>
css:
.navbar {
background-color: white;
}
.nav-links li a {
color: black;
}
What it looks like:
Screen Shot
In bootstrap, to color the ANCHOR links:
.nav a {
color: black;
}
You can also use Dev-Tools in the browser and right-click on the element you want to style, so it identifies the classes.
Create a class in the a elements you got in the nav bar. Name it something like blackletter for example. Then in css put color:black under .blackletter
Can someone have a look to this fiddle http://jsfiddle.net/pkcwtone/1/ and tell me why I am not able to put the image all right inside the navigation?
This is html:
<nav id="mainNavigation" class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Responsive navigation -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-2"> <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="http://s28.postimg.org/gc8ajkjq5/advance_logo.png" alt=""/>
</a>
</div>
<div class="clearfix"></div>
<div class="collapse navbar-collapse" id="navbar-collapse-2">
<!-- top navigation-->
<ul class="nav navbar-nav navbar-left">
<li>
Home
</li>
<li>
Accident<br>Management
</li>
<li>
Approved<br>Manufacturers
</li>
<li>
Our<br>Services
</li>
<li>
About<br>Advance
</li>
<li>
Contact<br>Us
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
</ul>
</div>
</div>
</nav>
This is css:
#mainNavigation.navbar-default{
/*background: #f9540a;*/
background:black;
width: 100%;
text-align: center;
font-family:'Droid Sans', sans-serif;
font-weight:700;
font-size:1.2em;
}
#mainNavigation.navbar-header {
float: left;
padding: 15px;
text-align: center;
width: 100%;
}
#mainNavigation .container-fluid{
height:auto;
overflow:auto;
}
.navbar-brand img{
float:left;
}
I've been playing with overflow... with clearfix..... with the height.... but it looks bad :S The text overlays the logo, which it shouldn't (I know I could use padding, but I've though it must be a way more natural to keep in mind the space that the logo occupies), and then, the logo look cut! :S
Anyone can see what am I doing wrong?
Cheers :)
Looks like the issue is here:
#mainNavigation.navbar-header {
what the above css is looking for is a div with id mainNavigation and class nav-header
however you add a space between them, it looks for the class within the mainNavigation:
#mainNavigation .navbar-header {
you will be able to resize the navbar to fit the logo, see the updated jsfiddle:
http://jsfiddle.net/pkcwtone/4/
I am having trouble getting bootstrap 3's navabar to be responsive on a mobile device. The navbar continues to span further than the mobile display, and I cannot figure out what I did wrong.
The Code:
(HTML)
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigationbar">
<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 img-responsive" href="index.html">
<img src="img/logo.png" width="320" height="85" alt="">
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="navigationbar">
<ul class="nav navbar-nav navbar-right">
<li>
Home
</li>
<li>
Getting Started
</li>
<li class="dropdown">
Products <b class="caret"></b>
<ul class="dropdown-menu">
<li>
Brain Seedâ„¢
</li>
</ul>
</li>
<li>
About Us
</li>
<li>
FAQ
</li>
<li>
Contact Us
</li>
<li>
<button type="button pull-right" class="btn btn-success">ORDER NOW</button>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
The Code: (CSS)
.navbar-fixed-top .nav {
padding: 20px 0;
}
.navbar-fixed-top .navbar-brand {
padding: 0 15px;
}
.page-content {
padding-top: 40px;
}
.img-center {
display: block;
margin: 0 auto;
}
.navbar .brand {
max-height: 40px;
max-width: 30%;
overflow: visible;
padding-top: 0;
padding-bottom: 0;
}
I notice you in your html code, you typed fixed height and width, which cancels the img-responsive class.
Start by removing that and go from there...enter link description here
My navbar seems to go out of whack. It's especially evident when I view the site on my mobile device, or just shrink my desktop window.
Below is a link to my site along with the code. I would love for my name to fit between my projects tap on the left and my e-mail and twitter icons on the right. Thank you for your help and time.
http://jocatcreative.com/
(trying to get past stack socials 2 link limit...
imugr dot com/0s4iJyr
imgur dot com/vqjiyEd)
(Edited to include screenshots)
<div class="navbar navbar-default">
<div class="container">
<div class="Heading Tag" align="center"><h2>Jovan S Hernandez</h2></div>
<button type="button" class="navbar-toggle" data-toggle="collapse"
data-target="#example-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>
</div>
<div class="collapse navbar-collapse" id="example-navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Projects <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li>JoCat Creative Media</li>
<li>Gesaffelstein Landing</li>
<li>Monthly Resolutions</li>
<li class="divider"></li>
<li>Home</li>
<li class="divider"></li>
</ul>
</li>
</ul>
<ul class="pull-right">
<i class="fa fa-envelope-o"></i> Email Me
<i class="fa fa-twitter"></i> Twitter
</ul>
</div><!-- .container -->
</div><!-- .navbar -->
DEMO: https://jsbin.com/qufelu/1/
https://jsbin.com/qufelu/1/edit?html,css,output
You were using some incorrect classes, missing tags (on the right aligned stuff), unclosed tag (collapse), and were using an outdated attribute from ancient history ( align="center") Also, you don't need to wrap the name inside a div.
CSS
.custom-navbar {
background: transparent;
border: 0px;
}
#media (max-width:767px) {
.custom-navbar .name {
font-size: 20px;
float: left;
margin: 0;
padding: 15px 0 15px 15px;
}
.custom-navbar .navbar-toggle {
margin: 10px 15px 0 0;
float: right;
}
}
#media (min-width:768px) {
.custom-navbar .navbar-header {
width: 100%;
margin: 0;
}
.custom-navbar .name {
text-align: center;
float: none;
}
}
HTML:
<div class="navbar navbar-default custom-navbar">
<div class="container-fluid">
<div class="navbar-header">
<h2 class="name">Jovan S Hernandez</h2>
<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>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="navbar-right nav navbar-nav">
<li><i class="fa fa-envelope-o"></i> Email Me</li>
<li><i class="fa fa-twitter"></i> Twitter</li>
</ul>
<ul class="nav navbar-nav navbar-left">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Projects <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li>JoCat Creative Media</li>
<li>Gesaffelstein Landing</li>
<li>Monthly Resolutions</li>
<li class="divider"></li>
<li>Home</li>
<li class="divider"></li>
</ul>
</li>
</ul>
</div>
<!-- .navbar-collapse -->
</div>
<!-- .container -->
</div>
<!-- .navbar -->
I am trying to change the image in my naviation to a larger size.
However by doing this the navbar get's malformed.
I have the code over here: http://www.bootply.com/941lMP3fj6#
The problem might be that the image is in an anchor tag. But not sure.
Try:
.navbar-brand
{
padding-top: 0;
}
Working: http://www.bootply.com/cCg5FvZyZP
Add this to your styles:
.navbar-brand
{
margin: 0;
padding: 0;
{
.navbar-brand img
{
max-height: 100%;
}
http://www.bootply.com/rAzwwIbCBI
You need to adjust the height of the navbar.
You can use this variable in LESS to adjust the height and it will center the navbar vertically and include all necessary padding:
#navbar-height
50px is the default.
How to adjust this in regular CSS is to change the min-height of .navbar and the height of navbar-fixed-top and then adjust padding of .navbar-nav.
This is how the top part should be structured (missing navbar-header):
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle" data-target=".navbar-responsive-collapse" data-toggle="collapse" type="button">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" rel="home" href="/" title="www.site.nl">
<img src="//placehold.it/200x51">
</a>
</div>
Example Bootply: http://www.bootply.com/tOoeM8o8Om
<div class="container">
<button class="navbar-toggle" data-target=".navbar-responsive-collapse" data-toggle="collapse" type="button">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="navbar navbar-collapse collapse navbar-responsive-collapse">
<div class="pull-left" style="margin-right: 15px;">
<a rel="home" href="/" title="www.site.nl">
<img src="//placehold.it/200x51">
</a>
</div>
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About</li>
<li>Link 1</li>
<li>Link 2</li>
</ul> <!-- end nav-->
<ul class="nav navbar-nav pull-right">
<li class="dropdown">
<strong class="caret"></strong> Select language
<ul class="dropdown-menu dropdown-menu-right">
<li>NL</li>
<li>IL</li>
<li>ENG</li>
</ul>
</li>
</ul> <!-- end nav menu right -->
</div> <!-- end nav-collapse -->
</div>
Put your logo inside the container.
The above code works!!
Check and let me know if you have any issues!!