Forum Moderators: not2easy

Message Too Old, No Replies

overlap color not working as expected

color from container on top not showing

         

csleh

9:47 pm on Jan 6, 2010 (gmt 0)

10+ Year Member



On the left is a fixed area. When the window is shortened horizontally, that info should and does slide under the main content.
The problem is the left stuff is only hidden if "content" has a background color. "main" is the div that overlaps the left stuff (parent of content). applying color to "main" is not working.
Ideally "main" will have an opacity applied so that the left stuff effectively fades before sliding under "content".

Thank you!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
<!--
body {
background-color:#CC9;font-family:"Lucida Sans", "Lucida Grande", Arial, Helvetica, sans-serif;
font-size:90%;
color:#000000;}
#wrapper {
margin:0 10% 1em;
text-align:left;
width:40em;}
#header {height:60px;background-color:#333;}
#nav{position:fixed; width:10em;margin-top:2em;z-index:1;}
#main{margin-top:2em;z-index:10;position:relative;background-color:#cc9;}
#content{float:left;margin-left:12em;}
h1{color:#fff;}
-->
</style>
</head>
<body>
<div id="wrapper">
<div id="header">
<h1>header</h1>
</div>
<div id="nav"><ul>
<li><a href="#">one thing here</a></li>
<li><a href="#">a second thing</a></li>
<li><a href="#">three</a></li>
</ul>
</div>
<div id="main"><!--an additional wrapper for the main content area -->
<div id="content">
<p>the goal is for the item on the left to be fixed, so when vertically scrolling it's always visible. If the window is too small though, this content should overlap. Ideally, the background color is applied to &quot;main&quot;, to allow &quot;content&quot; to have white space. This would also allow me to put transparency on &quot;main&quot;, so the viewer could see the overlap effect and not ge confused. Perhaps then &quot;content&quot; has color so the nav isn't viewable under text.</p>
</div><!--end content -->
</div><!--end main -->
</div>
</body>
</html>

monie

10:45 am on Jan 10, 2010 (gmt 0)

10+ Year Member



Do you use javascript to change the divs' styles?

csleh

12:05 am on Jan 11, 2010 (gmt 0)

10+ Year Member



Nope, the only change is the css property. The difference can be seen if the window is dragged horizontally.

But if the initial window is smaller than how the page is being designed, having the "middle" container with a background color overlap the "bottom" div is what I'm looking for.

Right now the "middle" is ignored and only the "top" is overlapping correctly.

monie

5:05 am on Jan 12, 2010 (gmt 0)

10+ Year Member



I think you don't see anything when you change main's bg color because it doesn't have a set height. Add border:1px black solid; to its style so you can see where it's going: as a 0px high div under the header. Its overflow is visible by default so you can see content div and the nav, but there's not much of main behind them.

If I drag the window horizontally, nothing changes. What browser are you using? (I'm using Safari.)

"This would also allow me to put transparency on "main", so the viewer could see the overlap effect and not ge confused. Perhaps then "content" has color so the nav isn't viewable under text."
Just fyi, if "main" is semi-transparent then all of its children will be semi-transparent. Setting its children's opacity:100%, frustratingly enough, will not make them opaque.

Hope this helps.

csleh

4:30 pm on Jan 12, 2010 (gmt 0)

10+ Year Member



Monie, thank you for the pointers. Once I started playing with what you were saying it turned out to be a float/clearing issue, so I've switched up properties for main and content divs -- ta da!
(Using firefox, by the way)

I'll try a background image for main to fake a fade effect now that I know opacity won't work.

Such relief, helps a lot.