Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dejo

Moderator emeritus
Original poster
Sep 2, 2004
15,982
452
The Centennial State
The Question: How do I get Overlay #1 to overlap the green, right-side the same way that Overlay #2 overlaps the red, left-side? Overlay #1 must be "tied-to" the left-side DIV, so that wherever the red area goes, Overlay #1 goes with it.

The Page:
Overlay Test

The Screenshot:
overlay_test.png


The Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<title>Float Test</title>
<style type="text/css">
body {
font-family: Verdana;
}
#container {
background-color: blue;
width: 450px;
height: 220px;
padding: 10px;
}
#left_side {
background-color: red;
width: 180px;
height: 200px;
padding: 10px;
float: left;
position: relative;
}
#right_side {
background-color: green;
width: 180px;
height: 200px;
padding: 10px;
float: right;
position: relative;
}
#overlay_box_1 {
background-color: yellow;
width: 200px;
height: 50px;
position: absolute;
top: 0px;
left: 100px;
opacity: 0.8;
}
#overlay_box_2 {
background-color: yellow;
width: 200px;
height: 50px;
position: absolute;
bottom: 0px;
right: 100px;
opacity: 0.8;
}
</style>
</head>
<body>
<div id="container">
<div id="left_side">LEFT LEFT LEFT LEFT LEFT LEFT LEFT LEFT LEFT LEFT
<div id="overlay_box_1">OVERLAY #1</div>
</div>
<div id="right_side">RIGHT RIGHT RIGHT RIGHT RIGHT RIGHT RIGHT RIGHT RIGHT RIGHT
<div id="overlay_box_2">OVERLAY #2</div>
</div>
</div>
</body>
</html>

P.S. My apologies to anyone who's red-green color blind.
 

cookie1105

macrumors 6502
Mar 27, 2006
426
0
London, UK
I hope this helps you:

I added z-index and changed left position to 150px for #overlay_box_1

Code:
#overlay_box_1 {
background-color: yellow;
width: 200px;
height: 50px;
position: absolute;
top: 0px;
[COLOR="Red"]left: 150px;[/COLOR]
opacity: 0.8;
[COLOR="Red"]z-index: 99;[/COLOR]
}

Here is how it looks:
 

Attachments

  • Picture 2.png
    Picture 2.png
    8.1 KB · Views: 84

dejo

Moderator emeritus
Original poster
Sep 2, 2004
15,982
452
The Centennial State
cookie1105 said:
I hope this helps you:

I added z-index and changed left position to 150px for #overlay_box_1

Code:
#overlay_box_1 {
background-color: yellow;
width: 200px;
height: 50px;
position: absolute;
top: 0px;
[COLOR="Red"]left: 150px;[/COLOR]
opacity: 0.8;
[COLOR="Red"]z-index: 99;[/COLOR]
}

Here is how it looks:

Thanks for the help. The z-index manipulation does the trick, except for in Internet Explorer. Grr... :mad:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.