CSS - Nested Divs With Proportional Size
Hi,
I'm trying to build a modal box tool. Yes I know downloadable solutions exist, but wisely or not I'm building from scratch. And the javascript is fine, but on the CSS I feel I'm not quite doing it right. The HTML structure is pretty straightforward: PHP Code: <div id="PopUpBox" class="SinglePopUpBox" style="display:none"> <div class="TopBar"> <div class="CloseX"><a href="javascript:closePopUp()"><img src="Images/WindowCloseX.PNG" /></a></div> <div id="PopUpBoxTitle" class="Title"></div> </div> <div id="PopUpContainer" class="Container"><b style="color:#FFFF00">...Connectiing...</b></div> </div> and I just stick that on any underlying page with a button to make it appear. Ajax connects and injects the chosen content into PopUpContainer. Here's the issue. PopUpBox I want to be a percentage of the screen, to work on any size window. It appears in the middle via percentages. TopBar within that is a fixed height. And then PopUpContainer should fill the rest of the PopUpBox. So I set height=100% on PopUpContainer. But then it overflows the box by exactly the height of TopBar. At first I thought "hey, this sounds like a job for clearfloat" but that doesn't work. And it shouldn't, because floats aren't the issue. The problem I believe is going to 100% of a variable size. % of (% - x) to be more precise. So I "fix" this by giving PopUpBox enough padding-bottom to match the size of TopBar. This immediately feels bad, and I don't even know why. But it looks good, so I was prepared to shut up and accept it. However, IE7 (and probably 6, if I wanted to try it) don't play along. (Ditto IE8 in compatability mode, naturally.) They don't seem to respect that height=100% at all, and will make the Container shrink or bust out depending on what's inside. So what's the right approach to doing this? I'm quite willing to make moderate changes to my approach, but less happy to do stuff like add 12 pages of javascript to resize the box. CSS: PHP Code: div.SinglePopUpBox { color: #FFFFFF; border: 1px solid #CCCCCC; background-color: #000000; position:fixed; z-index: 100; left: 15%; top: 15%; right: 15%; bottom: 15%; padding:0px; padding-bottom:31px; /* Made to match height of TopBar + Container margin + Container Border + this border */ } div.SinglePopUpBox div.TopBar { background-color:#000000; background-image: url(Images/TopBar-Black.PNG); width:100%; height:26px; vertical-align:bottom; } div.SinglePopUpBox div.TopBar div.CloseX { float:right; margin-right:5px; } div.SinglePopUpBox div.TopBar div.Title { font-weight:bold; font-size:14px; padding-top:5px; padding-left:10px } div.SinglePopUpBox div.Container { background-image: url(Images/BackgroundBlue.JPG); overflow:auto; height:100%; padding-left:20px; padding-right:20px; margin-left:3px; margin-right:3px; border: 1px solid #CCCCCC; } Similar TutorialsI could see this as potentially being really easy to do or really hard to do. I'm hoping for the former. Suppose I have 3 divs, A, B, C and that I want the total width of A + B + C to equal the width of the screen. Suppose also that I want them to be inline. How can I have B to be a fixed width while A and C expand depending on the screen width (such that the width of A = the width of C)? The Example I've read a bunch about how div's won't stretch to accomidate div's inside of them if they overrun the height/min-height set for the container div. How do I get around this? You can see the skeleton of the site above. It's fine unless you resize the window smaller than the content. I have set up a couple vertical boxes and filled them with 'column' boxes all nested within the parent vertical boxes. My problem is when, say, box #3 from the left has more content than the furthest left box, instead of stretching the parent to accommodate the content and push down the other parent horizontal box below, the content just flows behind the lower horizontal box. If the content in the furthest left box is the longest, this problem doesnt occur. The parent box is stretched to fit. Thx Joe ####################### html ######################### <html> <head> <meta http-equiv="Content-Type" charset=windows-1252> <link rel="stylesheet" href="test.css" type="text/css" media="screen,projection,print" title="Default" /> </head> <body id="savor-home"> <div id="main"> <div id="abovefold"> <div id="column-a"> <div id="type2"> blah<br> blah<br> blah<br> blah<br> </div> </div> <div id="column-b"> <div id="type1"> blah<br> blah<br> blah<br> blah<br> </div> </div> <div id="column-c"> <div id="type2"> blah<br> blah<br> blah<br> blah<br> </div> </div> <div id="column-d"> <div id="type1"> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> </div> </div> </div> <div id="maincontent"> <div id="column-a"> <div id="type1"> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> </div> <div id="column-b"> <div id="type1"> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> </div> </div> <div id="column-c"> <div id="type2"> blah<br> blah<br> blah<br> blah<br> blah<br> blah<br> </div> </div> </div> </div> </body> </html> ####################################### css ####################################### body { margin: 0px; background: #fff; } #main { width: 780px; min-height: 1500px; } #savor-home #abovefold { position: relative; top:0px; left:0px; width: 100%; width: 780px; clear: both; } #savor-home #abovefold #column-a { background: #eee; width: 185px; position: relative; top:10px; left:10px; display: inline; } #savor-home #abovefold #column-b { background: #ddd; width: 185px; position: absolute; top:10px; left: 205px; display: inline; } #savor-home #abovefold #column-c { background: #ccc; width: 185px; position: absolute; top:10px; left: 400px; display: inline; } #savor-home #abovefold #column-d { background: #bbb; width: 185px; position: absolute; top:10px; left: 595px; display: inline; } #savor-home #abovefold #type1 { background: url("/img/savor/featcontent1.jpg") no-repeat; width: 100%; /* hide from IEMac\*/ width: 185px; \width: 185px; w\idth: 165px; *width: 185px; /* end hiding */ padding: 10px; font: 12px verdana,arial,helvetica,sans-serif; color: #000; } #savor-home #abovefold #type1 h2 { color: #000; } #savor-home #abovefold #type1 h4 { color: #B5390F; padding: 1px; } #savor-home #abovefold #type1 a:link, #savor-home #abovefold #type1 a:visited { color: #000; font: bold 10px verdana,arial,helvetica,sans-serif; } #savor-home #abovefold #type1 a:hover { text-decoration: underline; color: #B5390F; font: bold 10px verdana,arial,helvetica,sans-serif; } #savor-home #abovefold #type2 { background: url("/img/savor/featcontent2.jpg") no-repeat; width: 100%; /* hide from IEMac\*/ width: 185px; \width: 185px; w\idth: 165px; *width: 185px; /* end hiding */ padding: 10px; font: 12px verdana,arial,helvetica,sans-serif; color: #000; } #savor-home #abovefold #type2 h2 { color: #000; } #savor-home #abovefold #type2 h4 { color: #B5390F; padding: 1px; } #savor-home #abovefold #type2 a:link, #savor-home #abovefold #type2 a:visited { color: #000; font: bold 10px verdana,arial,helvetica,sans-serif; } #savor-home #abovefold #type2 a:hover { text-decoration: underline; color: #B5390F; font: bold 10px verdana,arial,helvetica,sans-serif; } #savor-home #maincontent { position: relative; top:0px; left:10px; background: #0f0 url("/img/savor/maincontent.jpg") no-repeat; width: 770px; } #savor-home #maincontent #column-a { width: 256px; position: relative; top:10px; left:0px; } #savor-home #maincontent #column-b { width: 256px; position: absolute; top:0px; left: 256px; } #savor-home #maincontent #column-c { width: 256px; position: absolute; top:0px; left: 512px; } #savor-home #maincontent #type1 { width: 100%; /* hide from IEMac\*/ width: 256px; \width: 256px; w\idth: 236px; *width: 256px; /* end hiding */ padding: 0 10px 0 10px; font: 12px verdana,arial,helvetica,sans-serif; color: #000; border-right: 1px dotted; } #savor-home #maincontent #type1 h2 { color: #000; } #savor-home #maincontent #type1 h4 { color: #B5390F; padding: 1px; } #savor-home #maincontent #type1 a:link, #maincontent #type1 a:visited { color: #000; font: bold 10px verdana,arial,helvetica,sans-serif; } #savor-home #maincontent #type1 a:hover { text-decoration: underline; color: #B5390F; font: bold 10px verdana,arial,helvetica,sans-serif; } #savor-home #maincontent #type2 { width: 100%; /* hide from IEMac\*/ width: 256px; \width: 256px; w\idth: 236px; *width: 256px; /* end hiding */ padding: 0 10px 0 10px; font: 12px verdana,arial,helvetica,sans-serif; color: #000; } #savor-home #maincontent #type2 h2 { color: #000; } #savor-home #maincontent #type2 h4 { color: #B5390F; padding: 1px; } #savor-home #maincontent #type2 a:link, #savor-home #maincontent #type2 a:visited { color: #000; font: bold 10px verdana,arial,helvetica,sans-serif; } #savor-home #maincontent #type2 a:hover { text-decoration: underline; color: #B5390F; font: bold 10px verdana,arial,helvetica,sans-serif; } I have a div: .gallery{width:95%;margin:0 auto;padding:5px;border:solid 1px black;} and inside I have: .galleryItem{float:left;width:150px;padding:5px;height:150px;border:solid 1px black;} .spacer{clear:both;} Used to give height to the container div. The idea is to create and even sized box for varying jpgs. How do I get the inside divs to space themselves out evenly across the space? AND the get the jpg to align itself in the middle of its containing div? Thanks. First off - I'm not even sure if its technically allowed or correct but I am nesting 3 <div>'s in one container <div> (I assume this is ok - quite positive) So when positioning nested <div>'s I am running into problems. Here is the link http://www.nextwavehosting.net/new (looking at the bottom bar with the website thumbnail, info, and the word test) Here is a snippet of code... The container... Code: div.bottomInfo { position: absolute; top: 510px; left: 15px; width: 723px; height: 190px; z-index: 6; background-color: #EDEBE6; } The nested <div>'s Code: div.featured { position: relative; top: 15; left: 252; width: 150px; height: 114px; z-index: auto; } div.featInfo1 { position: relative; top: 20; left: 252; width: 150px; height: 35px; z-index: auto; } div.featInfo2 { position: relative; top: -32; Left: 670; z-index: auto; } the first nested <div> is positioned exactly how it should... the 2nd <div> is correct horizontally but vertically i would assume that it is still being positioned relative to the container... meaning that the second <div>'s top: 20; should be more like top: 140; to position it just below the first <div> yet the top: 20; works... the 3rd one is way off and is nearly impossible to position correctly... Any helpful tips or advice on this one? Hi All, I have the following html: Code: <div class="businessItem"> <div class="bizIcon"> <img src="GetImage.axd?type=1&business=3" alt="My Biz" /> </div> <div class="bizInfo"> <a href="business.aspx?business=3"> My Biz </a> <p> my biz </p> </div> <div class="bizContact"> <a href="www.myweb.com">www.myweb.com</a><br /> <a href="mailto:roman.rodov@gmail.com">roman.rodov@gmail.com</a><br /> 90294767 </div> </div> <div class="businessItem"> <div class="bizIcon"> <img src="GetImage.axd?type=1&business=4" alt="My Second Business" /> </div> <div class="bizInfo"> <a href="business.aspx?business=4"> My Second Business </a> <p> My second business </p> </div> <div class="bizContact"> <a href="www.myweb.com">www.myweb.com</a><br /> <a href="mailto:roman.rodov@gmail.com">roman.rodov@gmail.com</a><br /> 90294767 </div> </div> And the following CSS that applies: Code: div.businessItem { background-color: #66cc66; margin-bottom: 10px; width: 100%; padding: 10px 10px 10px 10px; } div.bizIcon { float: left; width: 64px; margin: 0px 10px 0px 0px; } div.bizInfo { float: left; width: 256px; } div.bizContact { float: left; width: 256px; } now the problem is that it looks like crap in FF2 and looks ok in IE7 (haven't tested IE6 yet). The idea is to have a full width div with 3 divs inside side by side. It looks *completely* different in FF2. Does anyone have any ideas? (I'm pretty new to CSS, just learning). I have the following CSS styles: Code: #content p { font-size: 24px; } .smalltext p { font-size: 12px; } Then, I create a #content div in my HTML with three paragraphs in it. I want the middle paragraph to have the .smalltext class, like this: http://www.toprival.com/temp/css_question.gif With the CSS the way I have it, the font size (12px) of the .smalltext paragraph is ignored. But if I change the CSS so both selectors are IDs, or so both are classes (and update the HTML accordintly), it works. Why is that? Hey everyone. Ran into a little snafu with CSS in firefox and NN last night. What I had, basically, was: Code: <DIV style='position:relative; margin-top:90px;'> <DIV style='position:relative; margin-top:14px;'> <img src='someimage.gif'> </DIV> <DIV style='position:relative; margin-top:8px;'> <img src='someimage2.gif'> </DIV> </DIV> the margin-top:14px was having absolutely no effect. The 8px one worked, but the 14px one only moved when I set it to over 90px, which would be more like absolute positioning, no? Now of course this could be rectified by just setting the top margin of the outter div to 104px and getting rid of the 14px one alltogether, but I'm sure there'd be instances where I'm using a php include for the inner divs or somthing and that wouldn't be an option. Can anyone offer me any thoughts or clarity on this? It worked fine in IE. Thanks. So, I have a div for content that contains three other divs for a three column display, like this: Code: <div id="content"> <div id="col1" class="column">filler filler filler</div> <div id="col2" class="column">filler filler filler</div> <div id="col3" class="column">filler filler filler</div> </div> now my CSS looks like this: Code: #content { top:10%; height: auto; background:#009999; border-width:thin; border-style:solid; border-color:#003333; overflow:hidden; } .column { position:absolute; top: 0%; width: 30.66%; display:block; } the problem is that the content div isn't resizing to fit the column divs. It's just a tiny thin strip at the top. It is also not hiding any of the column divs, it shows all of them. If I change height to, say, 200px it resizes to that value, and if I put text directly into that div (as opposed to the text in the column divs) it resizes to fit that. Any help/ideas would be greatly appreciated, thanks. Hello all, I've been scratching my head on this one for a bit. First of all, here's the site I'm working on: http://dev.discoverahost.com If you'll note, the background for the content is currently blank. I'm trying to get a background to cover that area. Here's the basic structure for that page: Code: <div id="main_header"> </div> <div id="main_navigation"> Home :: About :: Link :: Such and Such </div> <div id="content_wrap"> <div id="image_below_nav"> </div> <div id="content_main_header"> </div> <div id="content_main"> Lorem Ipsum blah blah blah </div> </div> Note: That's not all the code. You can look at the souce for the full thing. The background I'm trying to apply I want to go on the wrapper background (content_wrap). I've got it all defined in the CSS file, located he http://dev.discoverahost.com/css/style.css The problem is that the wrapper isn't expanding vertically to include the background, even though I've got plenty of text inside of another nested div. Now it works if I put content outside of these divs ... which I really don't want to do. Maybe I've got my structure all wrong for doing this kind of thing, but any and all help is very much appreciated. Thanks! - Adam if i create a div box with some transparency and then create another div insde it then the second div takes on the opacity of the containing one. how can i stop this? <div class = "f"> <div class = "s"> hello </ div> </div> the css code: .f{ background: 669999; width: 500px; height: 300px; position: absolute; top: 15px; left: 80px; z-index:1; /* for IE */ filter:alpha(opacity=60); /* CSS3 standard */ opacity:0.6; } .s{ background: 55ffcc; width: 400px; height: 200px; position: absolute; top: 15px; left: 20px; padding: 40px; } This could be argued that it belongs in a JavaScript forum but I think the core of the problem lies in where the information should go so I shall post it here. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>My site</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <style type="text/css"> #base { clear: both; padding-top: 1px; border-top: 1px solid #ffffff; border-bottom: 1px solid #ffffff; width: 100%; background: #0f0f0f; } /* end #base */ #main_block { background: #0000ff; margin: auto; text-align: left; width: 955px; } /* end #main_block */ #main_content { background: #ffffff; border-left: 1px solid #0000ff; border-right: 1px solid #0000ff; } /* end #main_content */ #top_main_content { padding-top: 1em; } #top_main_content ul { float: left; list-style-type: none; border-spacing: 0; border: 0; margin: 0; padding: 0; text-align: right; border-top: 1px solid #ff0000; height: 243px; width: 266px; } /* end #top_main_content ul */ #top_main_content ul li { color: #00ff00; width: 266px; border-bottom: 1px solid #ff0000; } /* end #top_main_content ul li */ #top_main_content ul li a { line-height: 26px; display: block; color: #00ff00; width: 266px; } /* end #top_main_content ul li a */ .indent { padding-right: 1.5em; } #top_main_content ul li a:hover { background: #cfcf00; color: #000000; } /* end #top_main_content ul li a:hover */ #top_main_content #rotating { z-index: 0; float: right; width: 687px; height: 242px; border-bottom: 1px solid #ff0000; border-top: 1px solid #ff0000; } /* end #top_main_content #rotating */ #default { position: absolute; visibility: visible; } /* end #default */ #a { position: absolute; visibility: hidden; } /* end #a */ #b { position: absolute; visibility: hidden; } /* end #b */ #c { position: absolute; visibility: hidden; } /* end #c */ #d { position: absolute; visibility: hidden; } /* end #d */ #e { position: absolute; visibility: hidden; } /* end #e */ #f { position: absolute; visibility: hidden; } /* end #f */ #g { position: absolute; visibility: hidden; } /* end #g */ #h { position: absolute; visibility: hidden; } /* end #h */ #i { position: absolute; visibility: hidden; } /* end #i */ </style> <script language="javascript"> function change_graphic(to_visible) { var num_elements = 10; var elements = new Array(num_elements); var i = 0; elements[i++] = "default"; elements[i++] = "a"; elements[i++] = "b"; elements[i++] = "c"; elements[i++] = "d"; elements[i++] = "e"; elements[i++] = "f"; elements[i++] = "g"; elements[i++] = "h"; elements[i++] = "i"; var temp = ""; for(i = 0; i < num_elements; i++) { document.getElementById(elements[i]).style.visibility = "hidden"; } document.getElementById(to_visible).style.visibility = "visible"; } // end function change_graphic(path) </script> </head> <body> <div id="base"> <div id="main_block"> <div id="main_content"> <div id="top_main_content" onmouseout="change_graphic('default');"> <ul> <li onmouseover="change_graphic('a');"><a href="#"><span class="indent">Link A</span></a></li> <li onmouseover="change_graphic('b');"><a href="#"><span class="indent">Link B</span></a></li> <li onmouseover="change_graphic('c');"><a href="#"><span class="indent">Link C</span></a></li> <li onmouseover="change_graphic('d');"><a href="#"><span class="indent">Link D</span></a></li> <li onmouseover="change_graphic('e');"><a href="#"><span class="indent">Link E</span></a></li> <li onmouseover="change_graphic('f');"><a href="#"><span class="indent">Link F</span></a></li> <li onmouseover="change_graphic('g');"><a href="#"><span class="indent">Link G</span></a></li> <li onmouseover="change_graphic('h');"><a href="#"><span class="indent">Link H</span></a></li> <li onmouseover="change_graphic('i');"><a href="#"><span class="indent">Link I</span></a></li> </ul> <div id="rotating"> <div id="default"><img src="images/default.gif" alt="" /></div> <div id="a"><img src="images/test_image_a.gif" alt="" /></div> <div id="b"><img src="images/test_image_b.gif" alt="" /></div> <div id="c"><img src="images/test_image_c.gif" alt="" /></div> <div id="d"><img src="images/test_image_d.gif" alt="" /></div> <div id="e"><img src="images/test_image_e.gif" alt="" /></div> <div id="f"><img src="images/test_image_f.gif" alt="" /></div> <div id="g"><img src="images/test_image_g.gif" alt="" /></div> <div id="h"><img src="images/test_image_h.gif" alt="" /></div> <div id="i"><img src="images/test_image_i.gif" alt="" /></div> </div> </div> </div> </div> </div> </body> </html> What I have is a set of links that when hovered will change the contents of the rotating div to reflect information about that particular link. As the code stands now, whenever any other item is moused over, the div will reset to the default div. What I would like to happen is whenever the top_content div is mousedoff (new word?), the content resets to the default. Thus I should be able to hover over a link, change the content of the rotating div, and move from that link directly to the content and mouse around over there all I want without changing back to the default div. To me, what I have should work in that I am thinking of nested divs as a parent/child relationship but that is obviously not how the browser is interpreting it. Any ideas on how I can achieve this? The JavaScript portion has been tested and works correctly. Edited: This code also pushes the side menu into the border in Opera. This problem was addressed and fixed in a previous thread but I broke it again. I am having a problem using nested hidden divs. I'd like to know if what I am doing is even possible. I have one div that is set to "display: none". Inside this div I have another set to "display: none". When I change the style of the outer div to "display: block", the inner div appears as well. Is there a way to keep the inner div hidden?? Not sure about this one- maybe someone can help shed some light on it? I have a <div> that contains a form. This div is dynamically-sized and floated left. What I want to do is place a nested <div> inside it so that it will cover the form below it. What's happening is that if I add the nested <div>, it pushes the form in it's container <div> down, which is obviously not what I want. I have tried using z-index on this nested <div> but with no success. Here is the code I'm using: Code: <div id="formdiv" style="display:block; padding-right:15px; padding-top:10px; border-right:#A0A0A0 1px dotted; float:left; width:auto; height:100%;"> <div id="overlaydiv" style="top:0px; left:0px; width:100%; height:100%; background-color:#FF0000; z-index:500;"></div> <form> ... </form> </div> There is other <div> tags before and after the 'formdiv', which are part of the page layout, but do not need to be covered by the 'overlaydiv'. I should note that 'formdiv' is itself inside a container <div>. I have tried various combination of CSS settings, but they don't give the same result. position:absolute; covers EVERYTHING within the uppermost container <div>, obviously not what I want. I've tried putting the form into it's own <div>, but I get the same result- the form just gets pushed below the 'overlaydiv'. Anyone have any ideas? Thanks, - skubik I have a container div which includes a #header div, a left-floated #content div, a #right div, and a #footer div. The #content div has a background image that does not want to extend all the way down within the div to snuggly join the footer in any IE browser. I've tried the Holly hack, adding a line-height, relative positioning but to no avail. The stylesheet is embedded in the html file. Here's the link: http://www.emaycreations.net/BuildWebsiteIII/Week6/finalexamPractice.html It looks great in NN, FF and Opera but neither IE 5 nor 6 displays the page correctly. Can anyone help? Mari-Anne in Montana I'm aiming to have a flash navigation console nested inside a div which extends outside the left boundary of it's parent div. It's very hard to explain exactly so I've drawn some diagrams. Here's what I'm trying to acheive: URL Here's the actual result i've come up with so far: http://www.advancedschoolyearbooks.com/divtest.html The results differ depending on the browser. In IE the horizontal positioning of the "NavInner" DIV is spot on but vertically it is hugging the top of the "Wrapper" table when it should be hugging the top of the "Navigation" DIV In firefox I can not see the image contained in the "NavInner" DIV at all. Here's a snip of my CSS: Code: body, html, #wrapper { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; background-color: #000000; height: 100%; } #wrapper { margin: 0 auto; text-align: left; vertical-align: middle; width: 100%; } #OuterFull { width: 100%; text-align: center; display: block; } #OuterBoxed { width: 969px; height: 650px; display: block; margin: 0 auto; } #LeftCol { width: 485px; height:650px; float: left; } #RightCol { width: 484px; height: 650px; float: left; background: url(bg.jpg) bottom left no-repeat; } #Navigation { width: 484px; height: 180px; float: right; overflow: hidden; text-align: right; margin: 0 auto; } #NavInner { width: 969px; height: 180px; float: right; text-align: right; position: relative; left: -485px; } #Content { width: 484px; height: 470px; float: right; overflow-y: auto; overflow-x: hidden; } Here's my HTML: Code: <body> <table width="100%" border="0" cellspacing="0" cellpadding="0" id="wrapper"> <tr> <td align="center" valign="middle"> <div id="OuterFull" align="center"> <div id="OuterBoxed"> <div id="LeftCol">LeftCol</div> <div id="RightCol"> <div id="Navigation"> <div id="NavInner"><img src="nav.jpg" /></div> </div> <div id="Content">Content</div> </div> </div> </div> </td> </tr> </table> </body> I want to have one main div that is horizontally centered on the page. Inside of it I want two nested divs, located right next to each other. It seems that the top property of the second nested div is being ignored, as it is being placed directly below the first nested div. Here is a sample that demonstrates what is happening. Am I doing something wrong or is what I'm trying to do fundamentally the wrong way to do it? Code: <html> <head> <style type="text/css"> #a { width: 800px; height: 800px; margin: 0 auto; text-align: center; background-color: #ff0000; } #b { position: relative; top: 50px; left: 50px; width: 300px; height: 300px; background-color: #0000ff; } #c { position: relative; top: 50px; left: 350px; width: 300px; height: 300px; background-color: #00ff00; } </style> </head> <body> <div id=a> <div id=b>test</div> <div id=c>test</div> </div> </body> </html> I have a menu system that I'm triyng to nest in my navbar div. The problem is that the absolute postioning of the nested divs are causing them to bust out of the navbar div. What can I do to remedy the problem. Here is my CSS Code: #header { width: 100%; height:145px; background-image: url(images/topbackground2.jpg); background-repeat: repeat; } #navbar { width: 122px; background-color:#3f79a1; position: relative; float: left; border; } #content { height:100%; background-color:#3f79a1; position: relative; float: right; } #footer { background-image: url(images/gradientsmaller2.gif); font: 10pt; background-color: #ccffcc; width: 100%; text-align: center; padding: 0 15%; clear:both; } Here is the html for the navbar div Code: <div id="navbar"> <div id="p7menu1" style="position:absolute; left:0px; top:15px; width:122px; z-index:106"><a href="javascript:;" onClick="P7_trigMenuMagic1('p7menu1',1);return false" onMouseOver="P7_rollCMenu1(event,'p7menu1',0)" onMouseOut="P7_rollCMenu1(event,'p7menu1',0)" onFocus="if(this.blur)this.blur()"><img src="images/Login.gif" width="122" height="20" name="p7mbut1" border="0" alt="menu 1"></a></div> <div id="p7menu2" style="position:absolute; left:0px; top:35px; width:122px; z-index:107"><a href="javascript:;" onClick="P7_trigMenuMagic1('p7menu2',1);return false" onMouseOver="P7_rollCMenu1(event,'p7menu2',0)" onMouseOut="P7_rollCMenu1(event,'p7menu2',0)" onFocus="if(this.blur)this.blur()"><img src="images/EditProfile.gif" width="122" height="20" name="p7mbut2" border="0" alt="menu 2"></a></div> <div id="p7menu3" style="position:absolute; left:0px; top:55px; width:122px; z-index:108"><a href="javascript:;" onClick="P7_trigMenuMagic1('p7menu3',1);return false" onMouseOver="P7_rollCMenu1(event,'p7menu3',0)" onMouseOut="P7_rollCMenu1(event,'p7menu3',0)" onFocus="if(this.blur)this.blur()"><img src="images/InstructorInfo.gif" width="122" height="20" name="p7mbut3" border="0" alt="menu 3"></a></div> <div id="p7menu4" style="position:absolute; left:0px; top:75px; width:122px; z-index:109"><a href="javascript:;" onClick="P7_trigMenuMagic1('p7menu4',1);return false" onMouseOver="P7_rollCMenu1(event,'p7menu4',0)" onMouseOut="P7_rollCMenu1(event,'p7menu4',0)" onFocus="if(this.blur)this.blur()"><img src="images/MyCourses.gif" width="122" height="20" name="p7mbut4" border="0" alt="menu 4"></a></div> <div id="p7menu5" style="position:absolute; left:0px; top:95px; width:122px; z-index:110"><a href="javascript:;" onClick="P7_trigMenuMagic1('p7menu5',1);return false" onMouseOver="P7_rollCMenu1(event,'p7menu5',0)" onMouseOut="P7_rollCMenu1(event,'p7menu5',0)" onFocus="if(this.blur)this.blur()"><img src="images/GradeBook.gif" width="122" height="20" name="p7mbut5" border="0" alt="menu 5"></a></div> <div id="p7submenu1" class="pviimenudiv" style="position:absolute; left:142px; top:35px; width:102px; visibility: hidden; z-index:101"> <table width="108" border="0" cellspacing="6" cellpadding="0"> <tr><td>stuff</td></tr> </table> </div> <div id="p7submenu2" class="pviimenudiv" style="position:absolute; left:142px; top:55px; width:102px; visibility: hidden; z-index:102"> <table width="108" border="0" cellspacing="6" cellpadding="0"> <tr><td>stuff</td></tr> </table> </div> <div id="p7submenu3" class="pviimenudiv" style="position:absolute; left:142px; top:75px; width:102px; visibility: hidden; z-index:103"> <table width="108" border="0" cellspacing="6" cellpadding="0"> <tr><td>stuff</td></tr> </table> </div> <div id="p7menubottom" class="pviimenudiv" style="position:absolute; left:10px; top:115px; width:102px; visibility: visible; z-index:111"> <table width="108" border="0" cellspacing="6" cellpadding="0"> <tr><td>stuff</td></tr> </table> </div> </div> Sorry for so much code. I'm completely frustrated! I can't seem to get this layout to work at all. I was using frames which was fine but I have to make this work without frames now. Thanks for any help. Hi, I've a problem designing with CSS. This is the html code: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>test</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="structure-yellow.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <div id="headimage">test</div> <div id="greybar">test</div> </div> </center> </body> </html> And the attached css file is: Code: div#main { border: solid #000000 1px; padding: 3px; width: 780px; margin: 0 auto 0 auto; } #headimage { vertical-align: middle; height: 100px; background: #FFFF00; } #greybar { position: relative; top: 3px; background: #CCCCCC; } Since the headimage and the greybar are nested within the main div, the 3px padding of the "main" div should be respected, however it's not. What I think is happenning is that the 3px padding of the main div is respected for the expected greybar position, and it is not updated after setting the "#greybar" position property on the CSS file. How can I solve this problem? I know that I could achieve the same effect adding a 3px white bottom border on the "#headimage" class, but I'm looking for more elegant solution based on block positioning. Any ideas? Thanks, Caste |