KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to set up a simple horizontal tab structure for a page I'm working on, and I'm running into some trouble with floating div's combined with z-index. Viewing the following code in a browser: <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> #main { width: 500px; z-index: 1;} .left { float: left; width: 96px; background-color: red; border: 2px solid orange; z-index: 2; margin-right: -2px } .right { float: left; width: 396px; background-color: #09c; border: 2px solid green; z-index: 3; } .clear { clear: both; } </style> </head> <body> <div id="main"> <div class="left"> LEFT </div> <div class="right"> RIGHT <br /> RIGHT </div> <div class="clear"></div> </div> </body> </html> Why doesn't the left div's orange border overlap the right div's green border?
Tags (comma-separated)
Save Edits
Cancel