I have some trouble with the positioning of my mobile menu.
It seems that chrome has a small shift from 1px then in the other browser and Ι don't know why. Αs well Firefox looks in a specific width range good, but not overall. Ι use bootstrap and bootstrap use noramlize.css to reset the elements.
Ι prepared it on jsfiddle and tried to figure out what the problem is but was not able to.
Ηere you can better see what Ι mean:
Ι use the normal navbar from bootsrap:
HTML
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#top-nav" aria-expanded="true">
<span class="sr-only">Toggle navigation</span>
<span class="hamburger-icon"></span>
</button>
<div style="" aria-expanded="true" class="navbar-collapse collapse in" id="top-nav">
<ul class="nav navbar-nav nav-top">
<li>
<a class="dropdown-btn small" type="button" href="reseller.php">
<span class="icon reseller-icon"></span><span class="text">Reseller</span>
</a>
</li>
<li>
<a class="dropdown-btn small" type="button" href="first_step.php">
<span class="icon wizard-icon"></span><span class="text">Data capturing</span>
</a>
</li>
<li>
<a class="dropdown-btn small" type="button" href="settings.php">
<span class="icon settings-icon"></span><span class="text">Settings</span>
</a>
</li>
<li>
<a class="dropdown-btn small" type="button" href="archive.php">
<span class="icon archive-icon"></span><span class="text">Archive</span>
</a>
</li>
<li>
<a class="modalbox dropdown-btn small" href="#modalbox-language-country">
<span class="icon search-icon"></span><span class="text">Language / Country</span>
</a>
</li>
<li class="visible-xs">
<a class="dropdown-btn small" href="#">
<span class="icon"></span><span class="text">Logout</span>
</a>
</li>
</ul>
</div>
</div>
Due the css is not that small, it may be better to see it directly on jsfiddle.
Here is my code: https://jsfiddle.net/nm7b8jw2/5/
Thanks for any help
The issue occurs because Firefox renders the .navbar-header element with a height of 31px where as in Chrome the element is rendered with a height of 30px.
Such issues usually are handled by tweaking the line-height property of the elements. With two changes in the CSS it can be aligned in all browsers.
One is:
#media screen and (max-width: 991px) {
body {
font-size: 13.5px;
line-height: 20px; } } /* Line 17: previous value was 19px */
The second is:
header .nav-top-wrapper .navbar-header .navbar-toggle {
margin: 0;
padding: 4px 0 4px 10px; /* Line 279: previous value was 5px 0 4px 10px */
font-size: 19px; }
Here is a working demo.
Related
I have a menu in my website which is not aligned.
Picture
How do I go about aligning all the text of nav menu with the text of the blue button on right? I have tried the following code which doesn't seem to work right.
HTML
<nav class="navbar bg-color3">
<div class="container-fluid">
<img src="/Content/images/uploads/photo-01.png" width="410" alt="PG Portal de Gastos" style="float: left; margin: 18px 10px 10px 0;">
<button class="round-toggle navbar-toggle menu-collapse-btn collapsed" data-toggle="collapse" data-target=".navMenuCollapse">
<span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
</button>
<div class="collapse navbar-collapse navMenuCollapse">
<div class="login-panel">
<ul id="nav-list" class="nav pull-right">
<li>Inicio</li>
<li>Beneficios</li>
<li> Funcionalides</li>
<li>Planes</li>
<li>Contacto</li>
<li class="sub-menu-parent">
<a class="btn " href="#">Iniciar Sesión <i class="icon right-icon icon-login"></i></a>
<ul class="sub-menu">
<li>
<a class="btn btn-primary" style="border: 1px solid transparent;" href="#Url.Action("Login", "Cuenta")">
Portal
</a>
</li>
<li>
<a class="btn btn-primary" style="border: 1px solid transparent;" href="http://web.com/">
Portal
</a>
</li>
</ul>
</li>
<a class="btn btn-primary" href="#Url.Action("Registrar", "Cuenta")">
Iniciar Prueba<i class="icon right-icon icon-download"></i>
</a>
</ul>
</div>
</div>
</div>
</nav>
You have to remove the padding on .navbar .nav li:
.navbar .nav li {
padding:0;
float:left;
}
At the moment there is a padding:5px which causes a gap aroud the buttons.
The problem is in the padding of the .navbar .login-panel .btn class. If you remove the padding there ( padding: 0 20px; ) the text is horizontally lined. If you want the padding in the rest of the menu make specific padding for each of the classes.
use padding instead of height for both (adjust padding-bottom and padding-top for height problems)
try in both blue and white space
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;
}
How do I center list items on a container-fluid navigation? I have been jsfiddling with this for hours. I havent gotten anything that works properly. Looked over a ton of websites for answers.
<nav class="navbar navbar-info 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="hidden-xs" href="#">
<div class="logo-container">
<div><img src="assets/img/logo-header-optimized.svg" alt="" height="52" style="margin:10px 0px 10px 0px"></div>
</div>
</a> <a class="visible-xs navbar-brand"><img src="assets/img/phone-logo-header-optimized.svg" alt="" height="22"></a> </div>
<div>
<ul class="hidden-xs nav navbar-nav navbar-right" style="margin-top:10px">
<li>
<button type="button" class="btn btn-inverse navbar-btn btn-raised" onclick="window.open('')"><strong> BOOK NOW </strong></button>
</li>
</ul>
</div>
</div>
<div class="container-fluid">
<div class="navbar-header">
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li> Introduction <i class="material-icons"></i>
</li>
<li> Amenities <i class="material-icons"></i>
</li>
<li> Hospitality <i class="material-icons"></i>
</li>
<li> Information <i class="material-icons"></i>
</li>
</ul>
</div>
</div>
</div>
First: The div <div class="navbar-header"> should have a "witdh:100%".
Second: between insert a div with this style="width: 60%; margin: 0 auto;"
The width: 60% depending of elements
I tried the solution by Julian and it lowers the button on the left and I dont think he wants that. The two solutions that I have are to add one of 2 css styles.
First one .navbar-header {padding: 0 300px;} this will center the list items but will also move the image with it
Second one .navbar-nav {padding: 0 300px;} this will center the list items but will also bring the button closer to the middle but still in the same row as the image.
If you want to dig deeper, I recommend reading this
I have a project where I have used a bootstrap navbar but broken it up into flexboxes in order to align the various parts per specification. I want to put a logo in the far left corner of the navbar, where navbar-brand is usually given, but I'm having no luck getting an image to show. The best I can do is get an image placeholder icon to show. Attached is an image of the navbar as it stands now.
The following is the HTML for the navbar:
<div class="container first-container">
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container navcell flex-navbar">
<div class="navbar-brand">
<!--<a class="navbar-brand" href="#">-->
<img src="images/SST.jpg" class=" navbar-brand sst-image"></img>
<!--</a>-->
</div>
<button class="navitem 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="navitem navbar-collapse collapse navbar-responsive-collapse">
<ul class="nav navcell navbar-nav">
<li class="active"><span class="navitem glyphicon glyphicon-home"></span> Home</li>
<li><span class="navitem glyphicon glyphicon-edit"></span> Services & Rates</li>
<li><span class="navitem glyphicon glyphicon-book"></span> Portfolio</li>
<li><span class="navitem glyphicon glyphicon-user"></span> About/Contact John</li>
<li><span class="navitem glyphicon glyphicon-log-in"></span> Log In</li>
</ul>
<form class="navcell navbar-form">
<input type="text" class="form-control" placeholder="Search" id="searchinput">
<button type="navbtm submit" class="btn btn-default">
<span class="navitem glyphicon glyphicon-search"></span>
</button>
</input>
</form>
</div><!-- Nav-collapse -->
</div><!-- Container -->
</nav>
</div><!--Container-->
The pertinent .css is
body {
margin-top:50px;
background: url('../images/marble.jpg') no-repeat center top scroll;
}
.container{
width: 100%;
}
.navbar-brand {
background-image: url('../images/SST.jpg') no-repeat;
position: relative;
}
.banner {
font-family: 'atlas_of_the_magiregular', cursive;
font-size: 1.7em;
line-height: 1.3em;
padding: 10px 8px;
margin: 10px 0px;
background-image: url('../images/Sic Semper Scroll.png') no-repeat;
background-position: 50% 50%;
position: relative;
}
I included the banner section in the .css to show how I've implemented the scroll image below the navbar. I've tried setting the brand logo to be an image in the HTML, a background image in the CSS, nothing. I can put text into the navbar-brand and set it's color, but I'm having no luck with my logo image. What can I try next?
The problem seems to be with the relative path you are using for the image.
If you use an image with an absolute URL it works fine. Try this to see what I mean:
<div class="navbar-brand">
<!--<a class="navbar-brand" href="#">-->
<img src="http://i.imgur.com/60PVLis.png" alt="" class="navbar-brand sst-image">
<!--</a>-->
</div>
If you want to use a relative path, you need to make sure it's leading to the folder that contains the image. In your CSS the path is ../images/SST.jpg, but in your HTML the path is images/SST.jpg. You need to find the right path.
As a side note, keep in mind that <img> is a void element. No closing tag is required. You can remove the </img>.
I would like:
1. The Free Quote Button to be forced right
2. At small screensizes I would like free quote button to remain to the right of the (icon bar button [mobile menu])
3. I don't want the navigation bar to take up an extra line when at smaller screen size
Fiddle:
http://jsfiddle.net/z7V4F/
HTML:
<!-- Nav bar -->
<nav class="navbar navbar-inverse navbar-fixed-top navi-style" role="navigation">
<!-- quote button-->
<!--Free Quote-->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button> <a class="navbar-brand menulogo" href="#">
My Site + Logo Makes This Long
</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<!--<li class="active">Home</li>-->
<li class="dropdown"> Info Tab<b class="caret"></b>
<ul class="dropdown-menu">
<li>Overview
</li>
</ul>
</li>
<li class="dropdown"> contact Tab<b class="caret"></b>
<ul class="dropdown-menu">
<li>Overview
</li>
</ul>
</li>
<li class="dropdown"> about Tab<b class="caret"></b>
<ul class="dropdown-menu">
<li>Overview
</li>
</ul>
</li>
<li class="dropdown"> More Tab<b class="caret"></b>
<ul class="dropdown-menu">
<li>Overview
</li>
</ul>
</li>
<div class="navbar-right"> Free Quote
</div>
</ul>
</div>
</nav>
1. The Free Quote Button to be forced right
I would use position: absolute; here to avoid excessive juggling with margins and paddings. This way it will always stay on the same line. This will look worse if your navbar-header and nav items are wider though than in your fiddle.
.navbar-right {
position: absolute;
right: 0;
}
2. At small screensizes I would like free quote button to remain to the right of the (icon bar button [mobile menu])
Put another <button> above the navbar-toggle with pull-right and visible-xs classes. This will place the button on the right side of the navbar-toggle and make it visible only on XS screen sizes.
<div class="pull-right visible-xs free-quote">Free Quote</div>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand menulogo" href="#">
My Site + Logo Makes This Long
</a>
Give hidden-xs class to the other button so It won't show up in XS screen sizes. (example in answer to number 3)
3. I don't want the navigation bar to take up an extra line when at smaller screen size
You can show smaller button on SM screen sizes to avoid the need for navbar to expand on two lines like this (by need I mean otherwise it is more likely that navigation items and the button will overlap each other):
<div class="navbar-right hidden-xs free-quote">
Free Quote
Free Quote
</div>
I would suggest that you show logo or text only in navbar-brand on XS screen sizes so that they won't jump to their own line when the screen size is only e.g. 320px wide.
4. Extra: Make it look nice
Give some padding and margin to those buttons to align them nicely.
.free-quote {
padding: 9px 5px 9px 0
}
.free-quote > .btn-xs {
margin-top: 4px;
}
Here is the fiddle: http://jsfiddle.net/z7V4F/3/
You need to have two buttons.
One within the navbar-header and one outside.
The button within the navbar-header should only be visible at the extra small screens, as everything not within navbar-header is hidden at xs.
Everything within navbar-collapse will be hidden (become a mobile menu) at extra small sizes.
Html:
<div class="menuquote navbar-right hidden-xs"> Free Quote
</div>
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button> <a class="navbar-brand menulogo" href="#">
My Site + Logo Makes This Long
</a>
<div class="menuquote navbar-right pull-right hidden-sm hidden-md hidden-lg"> Free Quote
</div>
</div>
http://jsfiddle.net/4nmzh/
To get the button to be forced left and to appear to the right of the mobile menu toggle, put this div:
<div class="navbar-right">
Free Quote
</div>
just before the navbar-header and change navbar-right to pull-right
This takes the button out of the navbar formatting and forces the button to the right as pull-right is bootstrap's float: right class.
To stop your navbar going on to two lines at very small screen sizes your options are:
Set a min-width on your <nav class="navbar">
.navbar {
min-width: 470px;
}
(see this demo)
Shrinking the size of your logo/text in your <a class="navbar-brand"> at small screen sizes using media queries e.g.:
#media (max-width: 500px) {
navbar-brand {
...
}
}
When your navbar is larger I have reduced the padding on the list items to make them stay on one line:
ul.nav li a {
padding-left: 8px;
padding-right: 8px;
}
This Demo should at least give you a starting point.
Hi you can move free quotes outside the tag and add absolute position to it
look at the fiddle: http://jsfiddle.net/z7V4F/4/
As I said i moved div containing free quotes outside navbar-collapse and added next css.
.custum-free-quotes{
position:absolute;
right:0;
top: 0;
}
.navbar{
position relative;
}