CSS - Two Column With Neg. Margin Float Problem
I have a page that has a header, footer, left content box, and right sidebar.
I'm using a negative margin on the content container to get the right sidebar to fill the space so I can keep a sensible order within the html code. The right sidebar isn't taking up the negative margin space like it should. It floats right but takes up residence under the content box. It works without negative margins if I put the right sidebar first in the order (before the content) but I shouldn't have to do that. It also works using absolute positioning on the right sidebar but this is going to be a problem for pages that will have content that takes up less space than the sidebar (because of the footer). I have uploaded the page on one of my servers:test page page so you can see it in action. Here's the CSS/HTML code: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><title>test</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <style media="screen"> body { margin: 0; padding: 0; text-align: center; } div#pageframe { border: solid 1px black; margin: 0px auto 0px auto; width: 741px; /* total pagewidth */ } div#headerbox { border: solid 1px gray; width: 741px; height: 95px; } div#whiteboxes { border: solid 1px red; width: 741px; float: left; margin-right: -210px; } #middlecontent { border: solid 1px purple; margin-right: 210px; text-align: left; } div#rightside { border: solid 1px yellow; width: 185px; float: right; } div#footer { border: solid 1px olive; float: none; width:741px; height:55px; clear: both; } </style></head> <body> <div id="pageframe"> <div id="headerbox"> <h1>This is the Header.</h1> </div> <div id="whiteboxes"> <div id="middlecontent"> <h1>middle content</h1> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus varius eleifend tellus. Suspendisse potenti. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Nulla facilisi. Sed wisi lectus, placerat nec, mollis quis, posuere eget, arcu. Donec euismod. Praesent mauris mi, adipiscing non, mollis eget, adipiscing ac, erat. Integer nonummy mauris sit amet metus. In adipiscing, ligula ultrices dictum vehicula, eros turpis lacinia libero, sed aliquet urna diam sed tellus. Etiam semper sapien eget metus.</p> <p>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus imperdiet mattis risus. In hac habitasse platea dictumst. Curabitur aliquam rhoncus nunc. Suspendisse sit amet purus in wisi egestas placerat. Nunc varius suscipit magna. Fusce commodo dolor vel felis. Nunc auctor elit vitae justo. Donec lorem. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus diam wisi, tincidunt et, sollicitudin a, ultricies quis, est. Sed ut velit.</p> <p>Aliquam sit amet mi. Pellentesque imperdiet metus vitae wisi hendrerit imperdiet. Donec molestie tortor quis odio rutrum mattis. Donec nec sem. Proin tempus tempor risus. Suspendisse odio. Donec id mi. Maecenas est orci, porttitor eget, vehicula at, rhoncus a, magna. Duis eu tellus. Donec blandit, orci quis commodo tincidunt, mi leo tempor enim, in hendrerit eros lacus blandit urna. Donec sed mi nec dui varius fringilla.</p> <p>Quisque pretium, augue non blandit ultrices, ipsum augue varius velit, a adipiscing nulla nunc consectetuer diam. Maecenas eu ante non dui euismod euismod. Proin est tortor, bibendum in, imperdiet quis, porta vel, purus. Quisque tincidunt tincidunt elit. Suspendisse a mi. Nam faucibus. Aliquam imperdiet pulvinar turpis. Vivamus sit amet elit a leo tincidunt varius. Cras et orci. Aenean non velit vitae risus posuere iaculis. Quisque porta nibh sed massa. Aliquam non ante. Proin semper ipsum nec enim. Maecenas vestibulum nisl non magna. Aenean auctor. Nulla tincidunt augue ac quam. Etiam ultricies purus et metus. Aliquam tempus dignissim felis.</p> <p>Curabitur euismod odio. Suspendisse potenti. Aliquam est augue, feugiat non, sodales nec, aliquet et, massa. Nulla eu tellus sed mi mollis aliquam. Fusce sed sem. Etiam tempus augue non nulla. Nunc pede ligula, fringilla in, lobortis et, dictum a, est. Sed accumsan, nisl vel suscipit scelerisque, arcu turpis dictum augue, ut sagittis metus pede non felis. Donec mollis ipsum eu sapien. Sed eget nisl. Nunc sem eros, dapibus consectetuer, molestie non, elementum sit amet, felis. Donec eu diam eu nibh tincidunt malesuada. Mauris fringilla volutpat odio.</p> </div><!-- end middlecontent --> <div id="rightside"> <h1>right frame</h1> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus varius eleifend tellus. Suspendisse potenti. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Nulla facilisi. Sed wisi lectus, placerat nec, mollis quis, posuere eget, arcu. Donec euismod. Praesent mauris mi, adipiscing non, mollis eget, adipiscing ac, erat. Integer nonummy mauris sit amet metus. In adipiscing, ligula ultrices dictum vehicula, eros turpis lacinia libero, sed aliquet urna diam sed tellus. Etiam semper sapien eget metus.</p> </div> </div><!-- end whiteboxes --> <div id="footer"> <p>FOOTER<br />Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus varius eleifend tellus. Suspendisse potenti.</p> </div> </div><!-- end pageFrame --> </body></html> Any help is greatly appreciated. Similar TutorialsJust when I think I'm starting to get a handle on things, I run into yet another mystery... Take something like this: Code: <div style="background: orange; float: left;"> This is floated. </div> <div style="background: blue; margin-top: 600px; "> This is not floated. </div> In IE6 (don't have 7 on this machine) and Opera, I get what I expect -- an orange element and 600 pixels below that, a blue element. In Firefox both the orange and blue elements are moved 600 down. Thinking it has something to with clearing, I add: Code: <div style="background: orange; float: left;"> This is floated. </div> <div style="background: blue; clear: left; margin-top: 600px; "> This is not floated. </div> IE6, same result. Firefox and Opera, both elements are now at the top of the page. (clear: both same result) So now I try just adding some other content to the page: Code: <p>This is some text.</p> <div style="background: orange; float: left;"> This is floated. </div> <div style="background: blue; clear: left; margin-top: 600px; "> This is not floated. </div> This mysteriously fixes the issue in Firefox, so now IE and Firefox display the same. Opera still groups the two colored elements together. I'm sure there's something simple I'm not understanding here...any ideas? I am working on a simple css design for my site. It has a header, footer, and I am trying to divide the content into two columns. the attempt is he http://www.jimpix.co.uk/rejig/008.htm I have the two content columns defined as: #leftcol { width:70%; float:left; border:1px solid black; } #rightcol { width:25%; float:right; border:1px solid black; } The above divs sit within a main 'content' div: #content { padding:10px; border-top:2px solid #999999; border-bottom:10px solid black; } But when I view the site in either IE6 or Firefox, the rightcol and leftcol divs do not sit within the content div, or at least, they don't appear to on the screen. Instead of the 'content' div expanding to contain the leftcol and rightcol divs, it just sits at the top, hence why there is a big black line at the top, instead of at the bottom, underneath the columns. Can anyone see what I am doing wrong please? Thanks Jim Hi all, I'm currently working on converting a table based site to a CSS table less one. I have a fairly good understanding of CSS, but have come across a problem and would like some help in sorting it out if possible. The code I am pasting here is a quick mock up of what I am trying to acheive. It is a 2 column page, with a header and footer. When I run this code in IE 6, it seems to work as I think it should. When I run it in Opera 9, the maincenter content seems to move to the top of the last float in left column. I assume that my css code is wrong or my understanding is wrong, or there is some quirk, hack etc that I should be using. Code: <!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> <!--Don't add anything above this line, you may change the DTD to match your page--> <title>Test Page</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <link href="stylesheet.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <div id="header">This is the header</div> <div id="main"> <div id="mainleft">stuff on the left<br /> more stuff on the left</div> <div id="mainleft1">stuff on the left<br /> more stuff on the left</div> <div id="mainleft2">stuff on the left<br /> more stuff on the left </div> <div id="mainleft3">stuff on the left<br /> more stuff on the left</div> <div id="mainleft4">stuff on the left<br /> more stuff on the left</div> <div id="mainleft5">stuff on the left<br /> more stuff on the left</div> <div id="maincenter">stuff on the right<br /> stuff on the right<br /> stuff on the right<br /> stuff on the right<br /> stuff on the right<br /> stuff on the right<br /> stuff on the right<br /> stuff on the right<br /> stuff on the right<br /> stuff on the right<br /></div> <div class="clear"></div> </div> <div id="footer">This is the footer</div> </div> </body> </html> CSS: Code: #container { width: 600px; text-align: center; margin: 20px auto 0 auto; } #header { width: 598px; margin: 0px 0px 0px 0px; border: solid 1px; } #main { margin: 20px 0px 0px 0px; border: solid 1px; float: left; width: 598px; overflow: auto; } #mainleft { margin: 5px 5px 5px 5px; float: left; width: 150px; border: solid 1px; display: inline; clear: left; } #mainleft1 { margin: 5px 5px 5px 5px; float: left; width: 150px; border: solid 1px; display: inline; clear: left; } #mainleft2 { margin: 5px 5px 5px 5px; float: left; width: 150px; border: solid 1px; display: inline; clear: left; } #mainleft3 { margin: 5px 5px 5px 5px; float: left; width: 150px; border: solid 1px; display: inline; clear: left; } #mainleft4 { margin: 5px 5px 5px 5px; float: left; width: 150px; border: solid 1px; display: inline; clear: left; } #mainleft5 { margin: 5px 5px 5px 5px; float: left; width: 150px; border: solid 1px; display: inline; clear: left; } #maincenter { float: left; display: inline; margin: 5px 5px 5px 5px; border: solid 1px; width: 424px; } .clear { clear: both; } #footer { margin: 20px 0px 0px 0px; border: solid 1px; width: 598px; } Some notes: 1. Originally I had the left hand stuff in a div called mainleft, but had trouble getting that to work. Would that be correct, to include all the code in one div, with smaller divs inside it? 2. The little boxes on the left will be different boxes on the page, but for the mockup they are all the same, with different ids. 3. After looking around, I found out about the overflow: auto; for inside the main div, which fixed a nice problem I was having (main not having any content bar floats). Is IE 6 displaying the code right, or is Opera 9? --> I just had a bit of play around before posting and if I add a div around all the mainlefts, the code seems to work in both IE 6 and Opera. So whould that be best, to stick with that? I think adding in the overflow:auto; fixed the problem I was having with that earlier. Would still apreciate any comments Many thanks Scott At the moment I have a css layout nearly done. It works fine in IE and Firefox except for that the left navbar does not push the footer down. Instead it jumps out the parent div. The 2nd (maincontent) and 3rd (right column) do push the footer down. This wouldn't be such a problem if the navbar would contain static content, but it is dynamic and database driven. A simple solution would be to move the navigate thing to the right bar, but sadly I'm not allowed to do that. Layout CSS code Code: #body { position:relative; margin:0 auto; width:94%; min-width:50em; max-width:70em; border: 15px solid #ffffff; } #header { /* border: 1px solid #000000;*/ height: 185px; background-color:#ffffff; background-image: url(../images/design/test3.jpg); } #outer_wrapper { background: #ffffff url(../images/design/background_3.gif) repeat-y left; border-top:none; border-bottom:none; } #wrapper { background: url(../images/design/background_2.gif) repeat-y right; } #container { width: 100%; float: left; margin-right: -200px; background: #ffffff url(../images/design/background_2.gif) repeat-y right; /*border:1px solid #000000;*/ } #content { margin-right: 200px; /*background: url(../images/design/background_3.gif) repeat-y left;*/ } #main { /*border:1px solid #000000;*/ margin-left: 150px; /* background-color:#bbbbbb;*/ } #left { position: absolute; top:189px; width: 140px; /* height: 100%;*/ float: left; text-align: left; /* border-left: 2px solid #bbbbbb;*/ font:normal normal normal 12px Verdana, Geneva, Arial, Helvetica, sans-serif; } #sidebar { width: 200px; float: right; clear:right; } #footer { /* border: 1px solid #000000;*/ background: #304773; height: 30px; } .last { margin-bottom: 0; } .clearing { height: 0; clear: both; } Div structu Code: <div id="body"> <div id="header"><h1>Welkom bij Overeem de Haas</h1> </div> <div id="outer_wrapper"> <div id="wrapper"> <div id="container"> <div id="content"> <div id="main"> </div> <div id="left"> <? include ("../include/navigatie.inc"); ?> </div> </div> </div> <div id="sidebar"> <? include ("../include/uitloggen.inc");?> <? include ("../include/winkelmand.inc"); ?> </div> <div class="clearing"> </div> </div> </div> <div id="footer"><p class="content"></p></div> </div> navigatie.inc code Code: <div id="navigatie"> <ul> <li class="menu">Navigatie menu</li> <li><a href="index.php">Home pagina</a></li> <li><a href="#">Wat is Overeem?</a></li> <? ... echo "<li><a href=\"#\">Contact</a></li>"; echo "</ul>"; echo "</div>"; ?> Live example Can anyone (dev)shed some light on this? I just can't get it to work without messing up the 3rd column. Background info: - I have validated the page and CSS, no problems there - Site is working properly in Firefox and IE, seems to be a margin issue in Safari -This margin issue is not the common Safari bug with a negative margin being applied to a floated element -I am using Safari in a windows environment, I do not have a Mac The problem: -in Safari the top margin on the content either is either not being applied at all or is being interpreted differently -it may be of note that I was having the same issue with IE, but was able to specify an IE specific style sheet for it, I don't believe this is possible in Safari? The website: http://www.lisa-noble.com/test/redo.html The HTML Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Site Test</title> <link rel="stylesheet" type="text/css" href="redo.css" /> <!--[if IE]> <link rel="stylesheet" type="text/css" href="iespecific.css" /> <![endif]--> </head> <body> <div id="top_filler"> </div> <div id="left_filler"> </div> <div id="right_filler"> </div> <div id="top_left"> </div> <div id="header"> </div> <div id="top_right"> </div> <div id="content"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> <p>Etc, etc, etc....</p> </div> <div id="bottom_filler"> </div> <div id="bottom_left"> </div> <div id="bottom_right"> </div> </body> </html> The CSS Code: * { margin: 0; padding: 0; } body { background: #fdd9e9; } div#top_filler { background: url(images/bg_slice_sm.png) repeat-x; width: 100%; height: 164px; position: fixed; top: 0px; z-index: 5; } div#left_filler { background: url(images/left_slice_sm.png) repeat-y; width: 174px; height: 100%; position:fixed; left:0px; z-index: 5; } div#right_filler { background: url(images/right_slice_sm.png) repeat-y; width: 161px; height: 100%; position:fixed; right: 0px; z-index:5; } div#bottom_filler { background: url(images/bottom_slice_sm.png) repeat-x; width: 100%; height: 76px; position: fixed; bottom: 0px; z-index: 5; } div#header { position: fixed; top: 0px; left: 37%; height: 125px; width: 316px; margin: 0 auto; background: url(pink_logo2.png) no-repeat; z-index: 25; } ul.NoBulletNoIndent { list-style-type: none; margin-left: 0px; padding-left: 0px } div#top_left { height: 314px; width: 221px; background: url(images/left_top_corner_sm.png) no-repeat; position: fixed; top: 0px; left: 0px; z-index: 5; } div#bottom_left { height: 175px; width: 176px; background: url(images/left_bottom_corner_sm.png) bottom no-repeat; position: fixed; bottom: 0px; left: 0px; z-index: 5; } div#top_right{ height:174px; width:174px; background: url(images/right_top_corner_sm.png) top no-repeat; position: fixed; top:0px; right: 0px; z-index:5 } div#bottom_right{ height: 602px; width:198px; background: url(images/right_bottom_corner2_sm.png) bottom no-repeat; position: fixed; bottom: 0px; right: 0px; z-index: 5 } div#content { margin: 40px 164px 0px 180px; position: relative; z-index: 1; } This is my first try at css and i have been at it about a week on and off. I have tried to use examples from here and the o'reilly CSS cookbook. I want to create a two column row of pictures with a caption. I selected DIV as the tool (my css is below). The container DIV looks great. I want the div.float, however, to start a second row when a third picture is added and to continue thereafter with successive two column rows. Unfortunately, each of my rows contain only one picture. here is my css style sheet. A demonstration of the problem can be seen at: http://www.yourline-online.com/demo05/?How_to_create_pages Code: div.float { float: left; BORDER-RIGHT: #808080 2px solid; PADDING-RIGHT: 2px; BORDER-TOP: #808080 2px solid; PADDING-LEFT: 2px; FONT-WEIGHT: lighter; FONT-SIZE: medium; PADDING-BOTTOM: 20px; MARGIN: 16px 2%; BORDER-LEFT: #808080 2px solid; COLOR: #000000; PADDING-TOP: 2px; BORDER-BOTTOM: #808080 2px solid; HEIGHT: 200px; WIDTH: 150px; BACKGROUND-COLOR: #ffffff; TEXT-DECORATION: none } div.float p { text-align: center; } div.container { border: 2px dashed #333; background-color: #ffe; } div.spacer { clear: both; } MY HTML is like this: Code: H1>How to create pages</H1> <P>The headings are used for splitting up the content file. An H1, H2 or H3 heading will dynamically split the document into new pages in the table of contents. An H4-heading is used as a heading within a page. See the following pages...<BR></P> <P></P> <DIV class=container> <DIV class=spacer></DIV> <DIV class=float><IMG height=100 alt="image 1" src="image1.gif" width=100> <P>caption 1</P></DIV> <DIV class=spacer></DIV> <DIV class=float><IMG height=100 alt="image 2" src="image2.gif" width=100> <P>caption 2</P></DIV> <DIV class=spacer> <DIV class=float><IMG height=100 alt="image 3" src="http://www.yourline-online.com/demo05/image3.gif" width=100> <P>caption 3</P></DIV> <DIV class=spacer></DIV></DIV></DIV> so, i have a form with rounded corners, which i've had no problems with in the past. the problem here is that the background color behind the box with the rounded corners is going to be user-generated and the box itself can change in width. my solution was to float the corners left and right and have the rest filled in the middle. works perfectly in firefox, giving the middle element an automatic width with margins on either side equal to the size of the corner images. however, IE decided to add in extra space between the 3 elements. ive tried giving the elements a display:inline-block property, but it didnt help. Code: #petition_letter { width: 330px; margin: 25px auto 0; } .lettertop .left, .lettertop .right { display: block; width: 15px; height: 15px; background-image: url(lettertop.gif); background-repeat: no-repeat; } .letterbottom .left, .letterbottom .right { display: block; width: 15px; height: 40px; background-image: url(letterbottom.gif); background-repeat: no-repeat; } .letterbottom .right { width: 40px; } .lettertop .left { float: left; background-position: top left; } .lettertop .right { float: right; background-position: top right; } .letterbottom .left { float: left; background-position: bottom left; } .letterbottom .right { float: right; background-position: bottom right; } .lettertop .middle, .letterbottom .middle { display: block; height: 15px; margin: 0 15px; background: #fff; } .letterbottom .middle { padding-bottom: 25px; padding-left: 15px; margin-right: 40px; } .lettercontent { border-bottom: 1px solid #fff; background-color: #fff; padding: 0px 30px; font-size: 12px; } <div id="petition_letter"> <div class="lettertop"> <span class="left"></span> <span class="right"></span> <span class="middle"></span> </div> <div class="lettercontent textColor"> blah blah </div> <div class="letterbottom"> <span class="left"></span> <span class="right"></span> <span class="middle"></span> </div> </div> I was working on a site today and I noticed a weird bug in IE 7. Couldn't find anything similar on the net, so I'll post here. PseudoCSS: Code: #topdiv{ width:960px; } #bottomdiv{ float: left; margin-left:15px; width: 300px; } .previous a{ background: url('images/previous.png') no-repeat; } .previous a:hover { background-position:0 -62px; } PseudoHTML: Code: <div id="topdiv"><a href="" class="previous">Link</a></div> <div id="bottomdiv">Content</div> When rolling over the image in topdiv, bottomdiv loses it's 15px margin-left and butts up against the left border of the parent div (Only in IE7). I removed the margin-left of bottomdiv and replaced it with relative positioning, left:15px. This fixed the issue and works cross browser. I guess my question is: is relative positioning "safer" than margins on floated elements? Hello, I am a fan of css and use it all the time. My one and only one problem with it is centering an image in a column that has been floated right. I've tried numerous ways to do this, but none have worked. Usually I end up adding a 2 column table, fixing the right column with x px, then adding images in rows in the left table column. This really does not center the image for all screen sizes, but it does move the images to the left. Also, margin-right:xpx would do about the same thing. This long-winded explanation leads to my css question: Is there a way to center images in a column that has been floated right? Maybe I am over-looking the obvious. Regards, Lee I'm doing a 2 column layout via css (my first attempt at doing full css layout) and I'm having some problems in firefox getting it to work right. Code: #navBar{ float: left; width: 20%; margin: 0px; padding: 0px; background-color: #eeeeee; border-right: 1px solid #0163CB; } #content{ width: 80%; float:left; } then my divs are as follows: <div id=navBar> stuff </div> <div id=content> more stuff </div> The problem is that in firefox the top of content sits directly to the bottom and left of the end of navBar . If I set conent width to 78% it seems to be fine but it there are borders inside content that i want to take up 100% of the remaining page. Thanks Dave Greetings, Basic Layout is: Page-Containter -> Header-Container -> Side-Container -> Content-Container -> Footer-Container Header is normal Side is a Float Left with a width of 250 Content has a left margin of 260 (to allow for the Side-Container) Footer is normal. Pretty basic. In the content area there are more divisions to handle different sections of data. The problem is that in some of the content sections, I need to have dynamically allocated "blocks" of data that form psuedo "columns". I do this by doing a float:left on each of the content blocks. (generally a 250px width) That way if I show 1 or 5, they all snug up next to each other and wrap properly in the browser. Still pretty basic. Until ... drum roll please ... the next section. Since the content is "float:left", it's removed from the layout and the following sections will just "snug up" next to the last content block. I want the section to "clear" the previous content division, but don't really have a clean way to declare the "height" of that division, due to the dynamic nature of the data. Silly Rabbit ... just do a clear:left !! In IE it works fine. In Firefox, the clear:left command is clearing the previous container! (side-container ... aka: left nav bar) First question: Which browser is right? is IE right and the clear:left should be contained to it's own division? or is firefox right and the clear:left checks all float:left regardless of division? Second question: If IE is right, what is the fix ... if Firefox is right, how should I actually structure this? I have the following: Quote: <div class="video"> <h1>Header</h1> <p><a href="#" title="title"><img src="images/01.jpg" alt="alt" width="150" height="150" class="img-left border"/></a></p> <div class="redBG border" style="margin-left:180px;"> <p><strong>Content</strong></p> </div> </div> <div class="video"> <h1>Header</h1> <p><a href="#" title="title"><img src="images/01.jpg" alt="alt" width="150" height="150" class="img-left border"/></a></p> <div class="redBG border" style="margin-left:180px;"> <p><strong>Content</strong></p> </div> </div> Not the nicest of code but it'll do for now. I want each div with class=video to come under one another but at the moment, the 2nd div starts just after the text in the first div and not actually under it. This is in the middle column of a 3 column CSS layout. The bottom is what the .video class has. Quote: .video { margin-bottom:10px; } Any help? I always seem to run into this problem and somehow get it fixed but this time I am stuck. I have a main wrapper and 2 footers that line up together and are all floated to the left. I'm trying to put in a column to their right that runs vertical called "right", to be spaced out about 110 px from the top of the page so it sits vertically below the banner and the navs. I tried giving it a left margin to clear the floated DIV's but to no avail. You can see the page he http://yourthreshold.com/playground/ It seems to clear in Firefox but not in IE .. The main CSS: Code: * { margin: 0; padding: 0; } body { margin:0; padding:0; background-color:#e5e5e5; } #wrapper { width: 640px; height: 720px; margin-left:0; margin-top:0; border: 2px solid gray; border-bottom: 0px solid gray; background-image:url(../images/banner.jpg); background-repeat:no-repeat; background-color:#c0c0c0; float:left; } #navigation { width: 640px; height: 22px; background-color:#c9c9c9; margin-top: 88px; } #insidewrapper { height:auto; width:99%; margin: 6px 1px 4px 1px; } /* Begin Left Side Info Boxes */ #sidebar { width:150px; height:600px; margin-left:2px; float:left; border:1px solid #666666; border-bottom:0px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:9px; color:#666666; background-color:#ffffff; } .infobox { height:123px; font:Verdana, Arial, Helvetica, sans-serif; font-size:9px; padding:3px; border-top:0px; border-left:0px; border-right:0px; } .infopic { margin-top:9px; } .infobutton { height:20px; border-bottom:1px solid #666666; padding-left:3px; } /* Begin Main Content */ #maincontent { width:465px; height:593px; margin-left:158px; border:1px solid; border-color:#666666; font:Verdana, Arial, Helvetica, sans-serif; font-size:12px; color:#333333; padding:3px; background-image:url(../images/background_trans2.gif); background-repeat:no-repeat; background-position:center; background-color:#ffffff; } /* Main Content for pages with textual content */ #content { width:97%; height:auto; padding:5px; } /* Main Content for pages with products */ #productWrapper { height:auto; width:100%; margin-top:10px; } #productLeft { height:auto; width:115px; float:left; } #productMiddle { height:auto; width:200px; margin-left:1px; float:left; } #productRight { height:auto; width:auto; } /* Begin Footer */ #footerlinks, #footer { width:640px; height:auto; text-align:center; float:left; } #footerlinks { border-right: 2px solid gray; border-bottom: 1px solid gray; border-left: 2px solid gray; background-color:#c0c0c0; font:Verdana, Arial, Helvetica, sans-serif; font-size:9px; letter-spacing:1px; color:#555555; padding-bottom:4px; } #footer { margin-left:0; margin-top:0; margin-bottom:15px; padding-top:8px; border-top: 0px; border-right: 2px solid gray; border-bottom: 2px solid gray; border-left: 2px solid gray; font:Verdana, Arial, Helvetica, sans-serif; font-size:9px; color:#555555; background-color:#a9a9a9; } /* Begin Rightside Column */ #right { border: 1px solid orange; width:195px; margin-left:650px; padding-top:111px; } Hello! I'm new to CSS, so any help would be greatly appreciated! I'm working on this page: sugarhooker[dot]com/testing/index2.html *The CSS is included in the head The right column is suppose to start where it says 'Are you hooked...' It should be right underneath the navigation bar. Anyone know what I'm doing wrong? Thanks in advance! Hi all, I'm not new to CSS in general but quite a novice when it comes to CSS positioning (absolute,relative etc.) I have built one simple web page as follows: http://www.jaysonsgroup.com/ztest/znuvo/z-index.html HTML: Code: <div id='contents'> <div id='main'> <a href='mailto:info@nuvohome.com'>info@nuvohome.com</a><br/><br/><br/><br/> ... *remainder text as you see on the web page**.. </div> <div id='footer'>We are working on that 100% green solution!</div> </div> The CSS as follows: Code: /* CSS global reset for all browsers */ * { padding: 0; margin: 0; } /******* main *******/ html, body, #contents { width: 100%; height: 100%; } /* * The "height" above is a hack for IE5+/Win. Below we adjust * it using the child selector to hide from IE5+/Win */ html>body, html>body #contents { height: auto; } body, p, td { font-family: Century Gothic, Verdana, Arial; font-size:10pt ; font-weight:normal; line-height: 17px; color: #007700; } body { margin: 0; background: url(../images/body/bg.jpg) repeat-y; } a, a:visited { color: #007700; font-size: 11pt; } #contents { margin: 0 auto; width: 500px; } #main { text-align: center; padding-top: 70px; margin-top: 15%; background: url(../images/goinggreen.jpg) no-repeat top center; } #footer { position: absolute; bottom: 0; text-align: center; width: 300px; background: url(../images/bioh-logo.gif) no-repeat top right; padding-top: 68px; padding-right: 160px; padding-bottom: 68px; } This page is done, except in Firefox the text is quite high (because I've set the margin-top: 15%; in the #main div) but in IE6, the main text seems to have a MUCH bigger top margin. Please preview on Firefox and IE to compare - you will notice a considerable margin difference. Just wondering why this is happening? There is an alternate version which I experimented with, using more on CSS positioning, but it still doesn't solve my problem..(and I sort of prefer the other version anyway)... http://www.jaysonsgroup.com/ztest/z...dex-strict.html Any advice on an IE6 hack or something to improve my code? TIA! If I have 2 tables in a div, does margin-top position the bottom table in relation to the top of the div or the bottom of the top table? My top table is absolute positioned top 0px, with a margin-bottom of 50px. The bottom table is positioned relative and has a top-margin of 50px, but is positioned relative to top of the div. Should it be positioned relative to the top table or do I need to put both tables in seperate divs to achieve the margin? I have two divs on a page. Neither div has a set height. I want to maintain a 50px vertical gap between them, regardless of the height of the top div. Can I achieve this with margins? I've tried using a bottom margin on the top div and a top margin on the bottom div, but the top margin of the bottom div seems to be positioning relative to the top of the top div, not the bottom of it. Can someone point out where I'm going wrong with this? Thanks Hi, My site looks fine in Dreamweaver, but when I upload it to my server and view it, there is a big margin at the top. I am using one of Dreamweaver's templates. All my CSS is currently in the header. the site is here How do I get rid of the spacing above the header? thanks Hi to all !! check out this little piece of example code: Code: <body bgcolor="#ffffff"> <div style="width: 720px; height: 850px; background-color: gray"> <div id="leftcolumn" style="float: left; width: 500px; height: 780px; text-align: left; background-color: #F4F4F4"> </div> <div id="rightcolumn" style="height: 780px; text-align: left; background-color: red"> </div> </div> </body> In IE, between the left and right columns, there is an empty space of 5 px, that has to me no explanation. In Netscape everything is fine, the left column is next to the right one. Setting the padding and margin to 0 won't correct the problem. You can set the right margin of the left column to "- 5px". This will solve in IE, but will mess everything up in Netscape. Question: is this an IE bug I just have to live with, or am I missing out on something...? Thanks for your help and bye Hi guys! I basically have a contain div, then, inside I have a logo div along with a 'middle' and footer div. The logo div is closed, and assigned a margin bottom property, the logo div also has a background:#FFFFFF; value. The middle div has a margin bottom value too, exactly like the logo div. All works well. But guess what, IE 6 doesn't seem to want to acknowledge these margins, and seem to want to add that margin to the navigation divs on the top and bottom of the middle div. Link: http://www.lewishamcab.org.uk/index2.php http://www.lewishamcab.org.uk/stylesheet.css Source code accessed from there as I don't know the exact problem. Hope someone can help! Regards, Joseph Man |