CSS - Clear: Left; Clears All Left-floated Divs
I've been unable to replicate this issue in IE, but it's plaguing all other "free" browsers I use (Firefox, Galeon, etc.).
Take a look at http://www.skudd.com/blog/view/1370 for example. The bar on the left is floated left, as are the label elements in my comment form. In the li of each form item, I have a br with the clear property set to "left". What I'm trying to accomplish is I want to clear the previous label, so as to prevent the "stair step" effect. Why would "clear: left;" in this case cause the element to clear everything that has been floated left? What should I try in place of it? Similar TutorialsHi all, I've got an item like this: <div (holder)> <div (image) style="float: left;">image</div> text here <div style="clear: left;"> </div> </div> But the trouble is that In the layout, I've got the menu floated left, too, and that 'clear: left;' seems to be clearing the left menu as well... Why? Cheers OK, so I have this nice clean form that I wanted to style up like the table-forms of old. I did it by floating the labels and form elements left, then clearing the labels left so they use their own lines. This works beautifully in Firefox and Safari, but IE (Win, at least) seems to think everything not cleared left should go on the same line! Is this a known IE bug/discrepancy? If so, is there a way to combat it without introducing meaningless elements to the markup (such as encasing each label/element pair in a div)? Here's some example HTML: html4strict Code: Original - html4strict Code <?xml version="1.0" encoding="iso-8859-1"?> <!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" lang="en" xml:lang="en"> <head> <title>Test</title> <style type="text/css"> @import url("style.css"); </style> </head> <body> <form name="form" action="test.php" method="post"> <label for="name">Name:</label> <input type="text" name="name" /> <label for="thoughts">Your Thoughts:</label> <textarea name="thoughts"></textarea> <label for="fun">Having fun?</label> <input type="checkbox" name="fun" value="yes" /> </form> </body> </html>
And the CSS: css Code: Original - css Code label { display: block; float: left; clear: left; width: 8em; margin-right: .5em; text-align: right; } input, textarea { display: block; float: left; }
Hey all, please check this page: http://www.trshady.com/eminemdownloads/ You'll see for floated grev divs. These are working well but the red sentence underneath is not adding margin like it should and it seems the block element is starting in line with the 1st floated div when it shouldn't as the width is too large. I'm unable to use clear as that would place the red sentence below the left hand menu which is floated.Any idea what I could do here? The only solution I see is to wrap the four boxes within a div and add a height larger then all boxes, but there must be a straight forward method. Cheers Hey, Why does this look different in IE and in Firefox? Code: <html><body> <div style="float:left;border:3px solid green;">Left div</div> <div style="width:200px;border:8px solid black;">Right div</div> </bodY></html> In FF, the right div's border starts at the same place as the left div's border. In IE, the right div's border starts to the right of the left div. Thanks in advance... No worries, made an obvious error. Please delete this =) ( sorry for waste of moderators time ) Hi i am trying to display small divs next to each other on one row, when i put clear left on the div that i want on the left, so that it puts it on the next line, the 3 divs then jump right down the page, putting a massive gap between this and the content above, is there a way to stop this happening? the code i have is html Code: <div id="arrow1">arrow1</div> <div id="arrow2">arrow2</div> <div id="arrow3">arrow3</div> Code: #arrow1 { background-image:url(images/arrow.gif) ; background-position:top left; background-repeat:no-repeat; width:176px; height:96px; float:left; display:inline; clear:left; } #arrow2 { background-image:url(images/arrow.gif) ; background-position:top left; background-repeat:no-repeat; width:176px; height:96px; float:left; display:inline; } #arrow3 { background-image:url(images/arrow.gif) ; background-position:top left; background-repeat:no-repeat; width:176px; height:96px; float:left; display:inline; } In Firefox, I've got a right div that is not repsonding to an auto width in FF. I am not a pro a CSS (yet ) and I hope that someone can give me the one line solution that I am missing. I've included a screen shot of the problem, any help is greatly appreciated. - K CSS Code Code: #MainContainer { float: left; width: auto; } #Main { margin-right: 0.2em; } #MainContent { padding: 0.5em 0.5em 0.5em 0.5em; } #SidebarContainer { float: right; width: 250px; border-top: 1px solid #C0C0C0; padding-top: 5px; clear: right; } #Sidebar { padding-bottom: 5px; background: #ADADAD; background-image: url(../images/SidebarBackground.jpg); background-repeat: no-repeat; clear:left; } #SidebarContent { margin: 0.2em 0.2em 0.2em 0.2em; } Hello, I'm trying to float an image inside a content div that is inside a wrapper div that already has a float left (nav) div earlier in the html. I know that this means that the floated image div will not be cleared until after the already floating nav div, since this is the one that comes earlier in the html and is quite large. It leaves a large gap until it clears the nav div. I have tried a couple of things, here is the page I'm working on and this is the css file This hasn't been tested on Windows, so I have no idea how it looks. It has been tested on the Mac: Safari, Opera, Netscape and Firefox display as described above, but IE Mac is way off whack. The current setup of the page is this: HTML: Code: <div id="content"> <div id="breadcrumb"><a href="http://www.huntacular.com/">Homepage</a></div> <div class="image1"> <img class="left" src="./images/pic.png" alt="Mystery Image" width"260" height="150"> <p class="red">Etiam vulputate rutrum dui. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p> </div> <div class="image2"> <img class="right" src="./images/pic.png" alt="Mystery Image" width"260" height="150"> <p class="orange">Donec accumsan. Pellentesque ac est vitae sapien scelerisque auctor. Nunc pede diam, interdum vel, dictum ut, egestas eget, metus. Maecenas eget sapien.</p> </div> <div class="another3"> <img class="left" src="./images/pic.png" alt="Mystery Image" width"260" height="150"> <p class="blue">Etiam vulputate rutrum dui. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed vulputate. Nulla ac leo sollicitudin mauris fringilla consectetuer.</p> </div> CSS: Code: img.left { float: left; border: solid 1px black; padding: 10px; margin-right:10px; margin: bottom: 10px; } img.right { float: right; border: solid 1px black; padding: 10px; margin-left:10px; } .image1 { border: red 1px solid; padding : 0px; } .image2 { border: orange 1px solid; padding : 0px; } .image3 { border: blue 1px solid; padding : 0px; } /* Trying to sort the float problem - this sends IE Mac nuts, not checked on IE Win */ .another:after { content: "."; display: block; height: 0; font-size: 0; clear: both; visibility: hidden; } .another {display: inline-table;} /* Hides from IE5/Mac \*/ * html .another {height: 1px;} .another {display: block;} /* End hide from IE5/Mac */ /* .clearer { clear: both; } */ p.red { color: red; } p.orange { color: orange; } p.blue { color: blue; } Is there a work around? I thought I'd found one in the third attempt - the one with blue text, but I'm not sure if I've implemented it correctly. Also, IE Mac isn't doing any of these correctly either (well, nearly the second one, but I haven't tested this stuff on Windows either. Is there a solution? Hi, Creating a Wordpress theme. I need help to clear:left JPG thumbnails in my 2nd-column div, but WITHOUT clearing the 1st-column div that is floated:left. In other words, I want these two columns to work independently, just like <TD> in html. Here is my setup -- it is a 2-column layout, with the left column being a navigational sidebar (navigation content automatically generated by wordpress), and the Right Column is the "real content" div. Wordpress generates the content in the right column, also. And since Wordpress generates the content based upon what the reader selects, I cannot assign any HEIGHT attributes to the Divs, because I do not know whether the selections have a lot of content, or very little. ----------------- HEADER DIV------------------------------------------ -- Sidebar Div-- __________ --- RIGHT DIV (not floated) ----------------- FOOTER DIV ---------------------------------------- (property of footer is set to clear:both) SIDEBAR DIV is float:left; width 160px RIGHT DIV is not floated, and contains all the content. 600px; Problem I need to solve: In column #2 -- the right div, I want to float-left small thumbnail jpgs, and write text flowing along the right side of the thumbnail. If the text does not naturally drop below the jpg, I want to clear:left to drop down to a new line and start the process over (new thumbnail, new text beside it). *** The problem is that when I clear:left on the jpg, it NOT ONLY clears the JPG, but also clears:left on the whole Sidebar DIV, thereby dropping the next line WAY DOWN on the page. So it looks like this: ___ HEADER ____ Sidebar __________________ Thumbnail #1: Text text text (clear:left clears everything....) __________________________ Thumbnail #2: Text ---- FOOTER --- Attempted solution: If I set the sidebar div to position:absolute, it works ok EXCEPT (and big except) that if there is not much content in the RIGHT DIV, then the FOOTER DIV is not low enough on the page, thereby overlapping the Sidebar Div. Obviously, this whole design could be EASILY accomplished with TABLES, but those are blasphemy these days, so I would like a more "modern" solution. I have googled this all day, and have not seen a solution. Help is appreciated. Hello, I have two columns, one is on the left and another in the middle (center). Left column is where I want it to be, central column is also aligned properly, however, it is below left column. I want it to be on the same level as left. See here see how it got below ? It is XHTML validated and CSS is fine too (some background color warnings). Plz help me to make central column go up. Thanks. at cookcommons the left nav divs are not working in FF but seem to be working fine in IE 7. IE6 does something different as well. I broke the left nav into 3 divs. Basically like this: Nav2 div Link Link Link Nav2 div close Search div search Search div close Nav2 div Link Link Nav2 close And in FF everything under the search gets messed up and pushed up in FF. In IE 6 I think I just have to adjust a margin or padding to make it work. IE7 looks great! Any help is greatly appreciated. Hi all, This is really annoying me and I don't think it should happen!! If you see this page, you will see one of the divs spans the whole page and it has gone behine the floated left element. Now if it wnt below it that would be OK as a block level element, but the content is in the right place. If you reduce the width it sits in its place OK. I think this is strange behavior.... is it correct????? http://www.wellandpower.net/website...req=www_contact Regards Charlie hi, this might be a simple question: i have a "sidebar" div and a "img-content" div. I floated "sidebar" left and "img-content" right. i want them to be side-by-side. in IE6, the "img-content" div is to the right of "sidebar," but is also below it. in other browsers, they sit side-by-side (which is what i want). this must be a common problem, so before i post my code, wondering if anyone can point me to the fix/hack to get the 2 divs to sit side-by-side in IE6? thanks, tim 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; } HTML: Code: <div id="title" class="title_lower_color"> <div class="title">TITLE</div> </div> <div id="main"> <div class="grouptitle1">Group 1 <div class="grouptext1">blah blah blah blah blah blah blah blah </div> </div> <div class="grouptitle2">Group 2 <div class="grouptext2">blah blah blah blah blah blah blah blah </div> </div> </div> CSS: Code: body { margin-top: 10px; margin-right: 10px; margin-left: 10px; } .title { font-family: "Times New Roman", Times, serif; font-size: 24px; color: #000000; font-weight: bold; background-color: #CCCCCC; border-color: #000000; border-bottom-style: solid; border-bottom-width: thin; width: 100%; float: left; position: relative; } .title_lower_color{ background-color: #666666; border-color: #000000; border-left-style: solid; border-bottom-style: solid; border-right-style: solid; border-right-width: thin; border-bottom-width: thin; border-left-width: thin; border-top-style: solid; border-top-width: thin; width: 100%; height: 40px; float: left; position: relative; } .grouptitle1{ color: #000000; font-style: normal; font-family: "Times New Roman", Times, serif; font-size: 14px; font-weight: bold; position: relative; background-color: #CCCCCC; border-color: #000000; border-style: solid; border-width: thin; margin-top: 10px; width: 300px; float: left; } .grouptitle2{ color: #000000; font-style: normal; font-family: "Times New Roman", Times, serif; font-size: 14px; font-weight: bold; position: relative; background-color: #CCCCCC; border-color: #000000; border-style: solid; border-width: thin; margin-top: 10px; margin-left: 10px; float: left; } .grouptext1 { color: #000000; font-style: normal; font-family: "Times New Roman", Times, serif; font-size: 12px; font-weight: normal; position: relative; background-color: #FFFFFF; border-color: #000000; border-top-style: solid; border-top-width: thin; width: 300px; } .grouptext2 { color: #000000; font-style: normal; font-family: "Times New Roman", Times, serif; font-size: 12px; font-weight: normal; position: relative; background-color: #FFFFFF; border-color: #000000; border-top-style: solid; border-top-width: thin; } I've only just started using CSS rather than tables. The title bit is ok. The problem is the main <div>. In Firefox l can't seem to get the two divs (grouptitle1 & grouptitle2) to float side by side. The only way l can do it is by setting grouptitle2 to a certain width. But l want grouptitle2 to fill the remaining width of the screen whatever size the browser is and not be a set width. Is there any way so that l can make the two divs appear side by side without adding a width to the grouptitle2?? here's a working version: Clicky Trying to achieve this: I'm having trouble figuring out how to float the right ad space correctly. This is what i've got so far: http://gatehouse.graffetto.com/floating_divs.html Code: Code: <html> <head> <style type="text/css"> .mainDiv {margin: 0; border: 1px solid black; padding: 10px; width: 600px; float: left;} .image {height: 100px; width: 100px; background-color: red; float: left;} .rightAd {float: right; background-color: blue; height: 250px; width: 300px; clear:right; margin-top: 300px;} </style> </head> <body> <div class="mainDiv"> <div class="image">test</div> <div class="rightAd">test</div> <div class="textDiv"> Text content </div> </div> </body> </html> I know this is simple i just can't figure it out for some reason.. thanks for any help. Hi, I have this page: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Page 1</title> <style type="text/css"> * { padding: 0; margin: 0; } p {padding: 0; margin: 0; } html {padding:0; margin:0;} .leftDiv { height: 100px; width: 30px; background-color: teal; float: left; } .mainDiv { padding: 5px 0 10px 0px; width: 200px; height: 20px; background-color: blue; } .mainPara { padding-left: 5px; } </style> </head> <body> <div id="contentDiv" style="width: 700px; height: 700px;"> <div class="leftDiv"> </div> <div class="mainDiv"> <p class="mainPara"> First Para </p> </div> <div class="mainDiv"> <p class="mainPara"> Second Para </p> </div> </div> </body> </html> And have two questions. First, why the gap between the left div and mainDiv in IE? I thought 3px bug was only for block elements with no dimensions? Second, why does padding left not take effect in FF untill I have overcome the width of the float? Even padding-left in the para does not take effect, which should be based off of its parent. Any help is appriciated, CJB Here's the site in Question: http://www.winchps.vic.edu.au It's a standard fixed width floated DIV columns with a wrapper. One thing it does have is a second DIV inside both columns to display the Gradient background over the top of the repeated background. It works perfect in Firefox & IE7 (with a tweak) but IE6 mkes the sidebar nested div drop below the original sidebar DIV click here for a screenshot for those lucky enough not to have IE6. Here's the CSS code for the basic layout: Code: body { font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif; font-size: 12px; text-align: center; margin: 0px 0px 60px 0px; padding:0px; border: 0; line-height: 2; } #header { width: 802px; } #wrapper { width: 802px; margin:0px; padding: 0px; text-align: left; margin: 0 auto; background: url(images/bodybg.jpg) center repeat-y; } #content { padding: 0px; margin: 0px; } #maingrad { background: url(images/winchcontentgrad.jpg) top left repeat-x; padding: 10px; } #main { width: 589px; float: right; background: url(images/winchcontentbg.jpg) repeat; border-left: solid 1px #000; border-right: solid 1px #000; } #mainstop { width: 589px; float: right; background: url(images/winchcontentbg.jpg) repeat; border-left: solid 1px #000; border-right: solid 1px #000; border-bottom: solid 1px #000; font-size: 10px; } #sidebargrad { background: url(images/winchsidebargrad.jpg) top left repeat-x; padding: 10px 5px 0px 10px; } #sidebar { width: 200px; float: left; background: url(images/winchsidebg.jpg) repeat; line-height: 2; font-size: 14px; border-left: solid 1px #000; border-right: solid 1px #000; } I obviously need to put a conditional comment in there, same for what I did for the minor IE7 tweak, but I'm struggling to suss out what's causing it, I haven't found the specific issue on any of the regular sites (PIE etc). Anyone got any ideas? I am new to css, and am eager to build the equivalent of a work-week calendar using only css. Basically, a five item table without using table tags. I have succeeded with firefox, but for some reason I am getting an odd reordering of the div elements in IE. I will post the html and the css below, and could really use some pointers. I am sure it has something to do with the float commands, but am not even sure what to call this problem to search for it! Here's the html page <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="killmer.css"> <title>Killmer's Science Page - Chemistry Assignments</title> </head> <body > <div class="left"> <h1><a href="chemcalendar.html" class="one">Chemistry Calendar</a></h1> </div> <div class="left"> <h1>Chemistry Textbook Online</h1> </div> <div class="left"> <h1>Chemistry Today Calendar</h1> </div> <div class="left"> <h1>Chemistry Today Textbook Online</h1> </div> <div class="right"> <img src="./images/logo.jpg" ></img> </div> <div class="right"> <h2>Chemistry Daily Assignments</h2>. </div> <div class="right"> <div class="monday"> <h1>MONDAY</h1> </div> <div class="tuesday"> <h1>TUESDAY</h1> </div> <div class="wednesday"> <h1>WEDNESDAY</h1> </div> <div class="thursday"> <h1>THURSDAY</h1> </div> <div class="friday"> <h1>FRIDAY</h1> </div> <div class="monday"> <h1>MONDAY</h1> </div> <div class="tuesday"> <h1>TUESDAY</h1> </div> <div class="wednesday"> <h1>WEDNESDAY</h1> </div> <div class="thursday"> <h1>THURSDAY</h1> </div> <div class="friday"> <h1>FRIDAY</h1> </div> </div> </body> </html> And here's the css a.one:link {color:black; text-decoration: none;} a.one:visited {color:black; text-decoration: none;} a.one:hover {color:red; text-decoration: none;} a.one:active {color:black; text-decoration: none;} body { background: url(./images/backgroundblend.jpg); background-repeat: repeat-y; background-color:black; } h1 { color:black; font-family:"times new roman",serif; font-size:100%; } h2 { color:silver; font-family:"times new roman",serif; } div.left { border:black; padding:3px; border-style:outset; border-width:2px; background-color:silver; width:150px; font-family:courier, monospace; float:left; clear:left; margin:5px; } div.right { margin-left:250px; margin-top:0px; margin-right:0px; margin-botton:0px; padding:0px; } div.monday { border:black; padding:3px; border-style:outset; border-width:2px; background-color:silver; width:15%; font-family:courier, monospace; margin:1px; float:left; clear:left; } div.tuesday { border:black; padding:3px; border-style:outset; border-width:2px; background-color:silver; width:15%; font-family:courier, monospace; margin:1px 1px 1px 1px; float:left;} div.wednesday { border:black; padding:3px; border-style:outset; border-width:2px; background-color:silver; width:15%; font-family:courier, monospace; margin:1px 1px 1px 1px; float:left; } div.thursday { border:black; padding:3px; border-style:outset; border-width:2px; background-color:silver; width:15%; font-family:courier, monospace; margin:1px 1px 1px 1px; float:left; } div.friday { border:black; padding:3px; border-style:outset; border-width:2px; background-color:silver; width:15%; font-family:courier, monospace; margin:1px 1px 1px 1px; float:left; } Thanks for the time! |