html - Placing 2 divs (top bottom) behind container div -
im trying place background divs behind container. thought place 1 div @ top , 1 @ bottom. make container have position:relative. top goes behind container. looks
http://oi62.tinypic.com/2lm3mvk.jpg
and how want
http://oi57.tinypic.com/5zjjvs.jpg
both blue divs suppossed behind , brown div container. red divs header/footer. how suppossed this?
<body> <div id="wrapper"> <div id="top"></div> <div class="blueleft"></div> <div class="padding"></div> <div id="container"></div> <div class="blueright"></div> <div id="bottom"></div> </div> </body> #wrapper{ width:100%; height:100%; } #top,#bottom{ background-color: red; width:100%; height:200px; clear:both; } #container{ background-color: brown; width:800px; height:600px; margin:0 auto; position: relative; } .blueleft{ width: 100%; height: 200px; background-color: blue; float:left; } .blueright{ width: 100%; height: 300px; background-color: blue; float:right; }
see if wanted.
http://jsfiddle.net/vleong2332/pq3823tz/
<div id="wrapper"> <div id="top"></div> <div class="bluetop"></div> <div class="padding"></div> <div id="container"></div> <div class="bluebottom"></div> <div id="bottom"></div> </div> css
#wrapper{ width:100%; height:100%; position: relative; } #top,#bottom{ background-color: red; width:100%; height:200px; clear:both; } #container{ background-color: brown; width:800px; height:600px; margin:0 auto; position: relative; } .bluetop{ width: 100%; height: 200px; background-color: blue; position: absolute; } .bluebottom{ width: 100%; height: 300px; background-color: blue; position: absolute; bottom: 200px; z-index: -1; } on html, changed class bluetop , bluebottom since more accurate semantically.
on css, since don't think you'd need float, removed them. used position: absolute on blue divs. top 1 doesn't need re-adjusted because flow puts want it. bottom, need position bottom on top of red since goes against normal flow. z-index put bluebottom behind brown div.
hope helps.
Comments
Post a Comment