I'm starting with Bootstrap and have a small problem with the navbar-element. I need to declare a container with the width of 1024px and have to add two navbars. On at the top and the other one below it. Both navbars need a distance from the right div of 0px.
(Stackoverflow doesn't want to let me post pictures, but I think it's much more easier if you can see what I mean: http://www.abload.de/img/asdjraik.png)
As you can see the first navbar is working correctly, but now I need another one below it. Padding from the container under it should be exactly 5px.
My problem is, that the other navbar gains the same padding from the top as the first navbar. I can't get it below the other one. When I define the following classes for this problem another one comes up:
.small-margin {
margin-top: 20px;
}
.big-margin {
margin-top: 110px;
}
My HTML looks like this:
<div class="navbar small-margin">
<div class="navbar-inner">
<div class="pull-right">
<ul class="nav">
<li>link 1</li>
<li>link 2</li>
</ul>
</div>
</div>
</div>
<div class="clear"></div>
<div class="navbar big-margin">
<div class="navbar-inner">
<div class="pull-right">
<ul class="nav">
<li>another link 1</li>
<li>another link 2</li>
</ul>
</div>
</div>
</div>
The second navbar appears on the left side of the first navbar and not below it. I tried a lot of CSS-fixes.
Anyone have a idea how to get the 2nd navbar below the first?
Thanks in advance!
I've tried your code and it's works
I also tried adding it into 1024px container
.container{
max-width: 1024px;
}
this is the result
Your css code must be conflicted with the bootstrap. maybe you could try wrapping each navbar with .row. I believe that this solution is surely make all navbar separated.
<div class="row-fluid">
<div class="span12">
... navbar 1 ...
</div>
</div>
<div class="row-fluid">
<div class="span12">
... navbar 2 ...
</div>
</div>
Related
I am using the materializecss framework from materializecss.com. I have a simple image that I place above the navbar from materializecss and there is a small white space. I checked the source and there is no margin, padding or border at all. The space goes away if I put the navbar above the image so I am not sure what the problem is.
<img id="header" src="/public/images/header.gif" alt="Header"/>
<nav class="grey darken-4">
<div id="navbar" class="nav-wrapper">
<ul id="nav-mobile" class="hide-on-med-and-down">
<li>Profile</li>
<li>Skills</li>
<li>Projects</li>
</ul>
</div>
</nav>
I am not using any other css besides the materializecss css file. Any ideas? I don't think that css has any margins anywhere as I don't see it when viewing the source for any of the elements.
Edit: Here is a jsfiddle: http://jsfiddle.net/0tL9up9s/ The list elements aren't appearing because I haven't copied over the javascript but you can still see the white space between the image and the navbar.
OK, I think it has to do with the fact that the image is display:inline and therefore has dimensions that include the line-height.
Setting your image to display: block will correct this issue.
CSS
#header { display:block; }
Or (HTML)
<img id="header" src="/public/images/header.gif" style="display:block" alt="Header"/>
Your fiddle: http://jsfiddle.net/0tL9up9s/1/
Adding a html {line-height: 0} to the end of the materialize.css file seems to fix the problem. I have no idea if it will break any other functionality though, so be careful.
http://jsfiddle.net/8ppt5zou/1/
<img id="header" style="display:block;" src="http://www.thousandwonders.net/covers/89/Bryce.Canyon.National.Park.jpg" alt="Header" >
<nav class="grey darken-4">
<div id="navbar" class="nav-wrapper">
<ul id="nav-mobile" class="hide-on-med-and-down">
<li>Profile
</li>
<li>Skills
</li>
<li>Projects
</li>
</ul>
</div>
</nav>
I'm a bootstrap 3 newbie, so please be gentle with me :) I know i'm going completely down the wrong route here. I've tried several approaches, this was just the latest. I've searched for bootstrap 3 websites doing the same thing, so i could learn from them, but can find any (some similar) but not with the big logo)
All I want is a big logo on the left taking up the full height of my header (about 100px) then small menu top right Contact us | Blog | Apply and main menu center bottom of the header space (but not under the logo) starting next to it (ideally centered) with 5 menu options. I tried to add a picture but it wont let me.
heres what I have : `
<style>
.smallmenu {
color: white;
background-color: #003300;
padding-right: 20px;
float: right;
font-size: 12px;
line-height: 50px;
}
.mainmenu {
background-color: #0000cc;
color: white;
padding-left: 200px;
float: right;
line-height: 30px;
font-size: 16px;
}
.logo {
background-color: #f11f18;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-lg-2 logo">
<img src="img/logo_en2.png" alt="logo">
</div>
<div class="smallmenu">
<ul class="list-inline">
<li> Contact Us</li>
<li> Apply Now</li>
<li> Blog</li>
</ul>
</div>
<div class="col-lg-10 mainmenu">
<ul class="list-inline">
<li>Menu 1</li>
<li>Menu 2</li>
<li>Menu 3</li>
<li>Menu 4</li>
<li>Menu 5</li>
</ul>
</div>
</div>
</div>
`
the coloured backgrounds are just to help me see where things go.
Of course as soon as I resize this, it falls apart. if someone could point me in the right direction.. with how the structure should be.. should I use navbars? should I be using col-xx-xx or not in a header? is it just one row, or should it be 2?
I guess on mobile it should have logo and small top menu and the main menu should be stacked.
Really appreciate any help with structure, site to look at or code samples I can learn from.
Thanks
First bit of advice I would give is start with the broad layout - where all the stuff on the screen is going to go - before you get down to trying to style menus etc. because you never know when inheritance is going to break something.
Is this (fiddle) basically what you're looking fro?
The key concept is:
<div class="row">
<div class="col"></div>
<div class="col">
<div class="row"></div>
<div class="row"></div>
</div>
</div>
Struggling a bit with some CSS navbar layouts and positioning the logo in the right hand side of the navbar.
Fiddle.
<div class="container-fluid">
<div class="navbar navbar-fixed-top navbar-default">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="offcanvas" data-target=".navbar-offcanvas" data-canvas="body">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand pull-right" href="#">
<img src="http://assets.inhabitat.com/wp-content/blogs.dir/1/files/2010/05/BP-Redesign-Contest-4-75x75.jpg" alt="Alternate Text for Image" >
</a>
<div class="navbar-offcanvas offcanvas navmenu-fixed-left">
<a class="navmenu-brand" href="#">eServices</a>
<ul class="nav nav-justified">
<li>Menu 1</li>
<li>Menu 2</li>
<li>Menu 3</li>
<li>Menu 4</li>
</ul>
</div>
</div>
</div>
</div>
Notice that the logo is positioned improperly.
When you hover over Menu 4, the effect is that the logo gets covered with the hover effect.
What I want to accomplish is something similar to this:
Notice that the logo is outside the navigation menu item, so that when I hover over the menu, the logo doesn't get covered.
Also, I need the logo to be positioned, right beside the collapsed navigation bar (as shown below) when the page is being viewed in mobile devices.
What proper css (or html tags) do I need to set to get this? Totally struggling with this for quite some time already.
Thanks.
Update: The fiddle must be viewed on Chrome (not sure why FF does not justify the nav items).
I think that I got the effect that you were going for. http://jsfiddle.net/0g9w8zza/4/. The following was added:
.nav {
padding-right: 75px;
}
.navbar-toggle {
position: absolute;
right: 75px;
top: 0;
}
Two things were added:
The hover state problem was happening because the menu technically extended all the way to the right side. Adding padding-right gives the logo white space in which to live (with your existing position: absolute; right: 0.).
The .navbar-toggle was also there, but hidden behind the image. position: absolute; right: 75px; puts it in the right place.
Note: Both classes assume your logo will always be 75 pixels. Alternate scenarios:
If you are using a CSS Pre-Processor like Less or Sass, use a variable here to make changes easier.
If you are using a fluid logo width, you can use percentages. I demonstrate this here: http://jsfiddle.net/0g9w8zza/6/. (In the Fiddle, logo width is 20%, and it still works; scale the Run window up and down to check).
(Let me know if this doesn't address your question, and I'd be happy to revisit).
I'm using the Pure CSS framework and my code looks like
<div class="container pure-g">
<header class='pure-u-1'>
<h1 class='logo'>
TEST
</h1>
<nav class="pure-menu pure-menu-open pure-menu-horizontal">
<ul>
<li>Example Link 1</li>
<li>Example Link 2</li>
</ul>
</nav>
</header>
</div>
Here's a JSfiddle: http://jsfiddle.net/ME4jv/
What I'm trying to do is line up the logo (to be floated left) with the navigation links (floated right), but both floating and the grid system aren't working.
Unfortunately you need to override the framework width declaration that has been assigned to the nav. Currently it is set to 100%;. This is why it is not floating up.
DEMO http://jsfiddle.net/ME4jv/2/
.pure-menu.pure-menu-open {
float:right;
display: block;
width: auto;
}
I'm trying to replicate the iOS 7 blur effect with CSS 3 to make a blurred menu bar with buttons above it. However, when I blur just the menubar, also the buttons and text in it gets blurred, which isn't what I want.
How the code looks:
<body id="containerid">
<div class="navbar navbar-static-top">
<div class="navbar-inner">
<div class="container">
<ul class="nav">
<li>Button 1</li>
<li>Button 2</li>
</ul>
</div>
</div>
</div>
</body>
Basically I just want to blur <div class="navbar navbar-static-top"> but not the buttons inside that div. How would one do that?
This one is the best example I have found: http://jsfiddle.net/CSS_Apprentice/WtQjY/415/
This requires: javascript $(document).ready(function(){
This is what I am trying to do with Bootstrap so it actually blurs the background of the image as well but having not as much luck.