Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Fixed navigation <div> elements with other elements over top

Posted on 2013-05-17
6
Medium Priority
?
329 Views
Last Modified: 2013-05-20
My test page:
http://sterlingmodular.com/test

Each of the colored bars running across the page is a <div> with position:fixed.

Now, I want to place the logo <img> and have it be overtop the colored bars, but it is behind (you can see part of it below the third bar). It comes after the bars in the markup, so I thought it would always be on top. The position:fixed changes that?

Is there some other way I can make the colored bars more of a background, so that I can put the logo overtop? Other than doing a position:absolute with the logo, set a z-index, etc.?

Basically, how do I keep those bars as position:fixed, but not have them affect other elements place overtop? They should be behind everything else.

Thank you!
0
Comment
Question by:bbdesign
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 2000 total points
ID: 39177250
This gets your answer http://jsbin.com/oduzoc/1/ but not really a good way of doing it.

<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Sterling Modular</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Michroma">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Alex+Brush">
<link rel="stylesheet" href="http://sterlingmodular.com/test/css/normalize.css">
<link rel="stylesheet" href="http://sterlingmodular.com/test/css/main.css">
<link rel="stylesheet" type="text/css" href="fhttp://sterlingmodular.com/test/loatbox/floatbox.css" />
<script src="http://sterlingmodular.com/test/floatbox/floatbox.js"></script>
<script src="http://sterlingmodular.com/test/js/vendor/modernizr-2.6.1.min.js"></script>
 <style>
 #logo {
	position: absolute;
	z-index: 99999;
	left: 0px;
	top: 0px;
}
 </style> 
</head>
<body>
  <div id="logo"><img src="http://sterlingmodular.com/test/img/lg_sterling-modular.jpg" alt="Sterling Modular" width="141" height="47" border="0" /></div>
<div id="nav1" class="redbar">

	<ul>
		<li><a href="">INTERNATIONAL SALES</a></li>
		<li><a href="">PRESS / REVIEWS</a></li>
		<li><a href="">ABOUT US</a></li>
		<li><a href="">DOWNLOADS</a></li>
		<li><a href="">CONTACT</a></li>
		<li><a href="">SHOPPING CART</a></li>
	</ul>
</div>

<div id="nav2" class="lightbar">
	<div id="tagline">Fine Studio Furniture from the Most Respected Name in the Industry</div>
</div>

<div id="nav3" class="darkbar">
	<ul>
		<li><a href="">U.S. RETAILERS</a></li>
		<li><a href="">ABOUT CONSOLES AND ACOUSTICS</a></li>
		<li><a href="">PHOTO GALLERY</a></li>
		<li><a href="">STERLING USERS</a></li>
	</ul>
</div>

<div id="wrapper">
	

	<p>Sample default font size and styling for Michroma.</p>

	<p class="cursive">Yes... You Have Arrived</p>

	<p><a class="btn">SAMPLE BUTTON</a></p>

	<p style="width:200px;height:100px;background-color:#9b1d30;text-align:center;">SAMPLE RED COLOR</p>
</div>

<div id="nav4" class="lightbar">
	<ul>
		<li><a href="">ACCESSORIES</a></li>
		<li><a href="">HIGH END MASTERING</a></li>
		<li><a href="">CUSTOM SHOP</a></li>
	</ul>
</div>

<script src="http://sterlingmodular.com/test/js/vendor/jquery-1.7.2.min.js"></script>
<script src="http://sterlingmodular.com/test/js/plugins.js"></script>
<script src="http://sterlingmodular.com/test/js/main.js"></script>

</body>
</html>

Open in new window

0
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39177258
I would probably make your 3 top bars one image, a thin slice that repeats in the background of a header div.  Then use css to make the image on the top left (change to a transparent png) and float the logo div to the left and margin right.  Then you will have the nav text for the 3 levels to the right of the logo.

<div id="header">
     <div id="logo">myimage</div>
     <div id="three_navs">
           <div id="top_nav">stuff</div>
           <div id="mid_nav">stuff</div>
            <div id="bottom_nav">stuff</div>
     </div>
</div>

Open in new window

0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 39177424
If you want something to be fixed background, the turn it into an image and set it as the fixed background.  If you want it to be part of content, then learn to use css to do real layout instead of just plopping thing in a page using fixed and/or absolute positioning.

Cd&
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bbdesign
ID: 39178497
My reasoning behind doing the separate <div> elements is because I may want to use those same backgrounds elsewhere in the website. I thought I would define them once, and reuse as necessary. Maybe I can put all three in a <div> and fix that <div>, instead of fixing each individual one?

Thanks for your input, I will go through this in more detail tomorrow.
0
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39179307
If you want to use the same background in other parts of the site, just set it up as a sprit.  

Consider this when taking the extra steps to make a sprit; assume the think slice is 3k, viewed a 10,000 times is about 30 megs of bandwidth.  If you save 2k by using the sprite, that's 20 megs of bandwidth.     I think you would need to see a million page views before the bandwidth savings make a difference.
0
 

Author Comment

by:bbdesign
ID: 39182601
Thanks for your good advice. I'm still working on it, but I think I know what to do now.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CSS3 Custom checkboxes This article shows how to style the checkbox form element using only CSS. Works in: Chrome, FF, Safari, Opera, IE9+ Uses modernizr.js to check for :checked pseudo class, falling back to plain old checkboxes (IE8 and bel…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question