![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
First, the code: div id="menu" style="float: left; background: red; width: 50px; height: 500px"></div div id="main" div id="header" style="background: green; color: white" div id="title" style="float: left; padding-left: 200px">hello,<br />hello,</div div id="search" style="float: left; padding-left: 200px">world! br />world!</div div id="end"> </div /div div id="body" style="background: blue"> </div /div Here's how it renders: http://www.frostjedi.com/terra/scrip...at-height.html The problem is that the text that I'd like to appear in the green dive appears, instead, in the blue div. ie. the height of "header" is being decided by "end" exclusively and since "end" isn't the same height as "title" or "search", the background of "header" isn't taking up as much space as it should. This is, as I understand it, how floats are supposed to work, but I'd still like both hello, worlds! to have a green background and not a blue one. Is there a way I can achieve the same effect (eg. hello being padding 200px on the left and world! another 200px more on the left? |
#3
| |||
| |||
|
|
First, the code: div id="menu" style="float: left; background: red; width: 50px; height: 500px"></div div id="main" div id="header" style="background: green; color: white" div id="title" style="float: left; padding-left: 200px">hello,<br />hello,</div div id="search" style="float: left; padding-left: 200px">world! br />world!</div div id="end"> </div /div div id="body" style="background: blue"> </div /div Here's how it renders: http://www.frostjedi.com/terra/scrip...at-height.html The problem is that the text that I'd like to appear in the green dive appears, instead, in the blue div. ie. the height of "header" is being decided by "end" exclusively and since "end" isn't the same height as "title" or "search", the background of "header" isn't taking up as much space as it should. This is, as I understand it, how floats are supposed to work, but I'd still like both hello, worlds! to have a green background and not a blue one. Is there a way I can achieve the same effect (eg. hello being padding 200px on the left and world! another 200px more on the left? |
#4
| |||
| |||
|
|
On Nov 9, 1:07 am, yawnmoth <terra1... (AT) yahoo (DOT) com> wrote: First, the code: div id="menu" style="float: left; background: red; width: 50px; height: 500px"></div div id="main" div id="header" style="background: green; color: white" div id="title" style="float: left; padding-left: 200px">hello,<br />hello,</div div id="search" style="float: left; padding-left: 200px">world! br />world!</div div id="end"> </div /div div id="body" style="background: blue"> </div /div I am really confused about what you are trying to do because you are not using CSS styles. The page is appearing like it is coded. Maybe you need to do some research on CSS http://www.w3.org/Style/CSS/ A CSS style will be like this: h1{ font-size:1.5em; line-height:125%; text-align:center; background-color:#009933; border:2px solid #000000; color:#FFFFFF; } The styles can be in the head (<style type="text/css">) section or on a separate style sheet (<link rel="stylesheet" href="example.css" type="text/css>). They can also be located in the body of the page, but still require (<style type="text/css>) to use. Hope it helps, Daniel |
#5
| |||
| |||
|
|
On 2007-11-09, yawnmoth <terra1024 (AT) yahoo (DOT) com> wrote: First, the code: div id="menu" style="float: left; background: red; width: 50px; height: 500px"></div div id="main" div id="header" style="background: green; color: white" div id="title" style="float: left; padding-left: 200px">hello,<br />hello,</div div id="search" style="float: left; padding-left: 200px">world! br />world!</div div id="end"> </div /div div id="body" style="background: blue"> </div /div Here's how it renders: http://www.frostjedi.com/terra/scrip...at-height.html The problem is that the text that I'd like to appear in the green dive appears, instead, in the blue div. ie. the height of "header" is being decided by "end" exclusively and since "end" isn't the same height as "title" or "search", the background of "header" isn't taking up as much space as it should. This is, as I understand it, how floats are supposed to work, but I'd still like both hello, worlds! to have a green background and not a blue one. Is there a way I can achieve the same effect (eg. hello being padding 200px on the left and world! another 200px more on the left? #end { clear: both }. Except then it also clears the menu on the left. So instead set overflow: hidden on #header. It doesn't work in IE but for that there's something weird you can do with a property called "zoom" I think. |
#6
| |||
| |||
|
|
Ben C wrote: snip It's amazing how often this problem comes up (i.e., containers collapsing due to floats being out of the document flow). There needs to be a standard property to do what 'overflow: hidden;' does. The IE thing is: #container { zoom: 1; } |
#7
| |||
| |||
|
|
On Nov 10, 3:51 am, "John L." <remov... (AT) edombmtech (DOT) co.uk> wrote: Ben C wrote: snip It's amazing how often this problem comes up (i.e., containers collapsing due to floats being out of the document flow). There needs to be a standard property to do what 'overflow: hidden;' does. The IE thing is: #container { zoom: 1; } Why does "overflow: hidden" / "zoom: 1" work? How cross browser compliant is it? |
#8
| |||
| |||
|
|
On 2007-11-10, yawnmoth <terra1024 (AT) yahoo (DOT) com> wrote: On Nov 10, 3:51 am, "John L." <remov... (AT) edombmtech (DOT) co.uk> wrote: Ben C wrote: snip It's amazing how often this problem comes up (i.e., containers collapsing due to floats being out of the document flow). There needs to be a standard property to do what 'overflow: hidden;' does. The IE thing is: #container { zoom: 1; } Why does "overflow: hidden" / "zoom: 1" work? How cross browser compliant is it? Overflow: hidden works because it makes the box a new "block formatting context", which basically means floats that start inside it stay inside it and floats that start outside it stay outside it. Other special rules for BFCs are mostly consequences of achieving those two aims in a reasonably helpful way. It's all defined in CSS 2.1 (see 9.4.1 and 10.6.7) and works in Firefox, Opera, Konqueror, Safari, and in any other CSS 2.1-conforming browser. So in a sense it works because the spec says so. But why specify it like that? Well, they specify it for boxes with any value of overflow other than visible. You can see why you might want floats inside a scrolling box to be isolated from floats outside it-- so the box doesn't have to keep reflowing around them as it scrolls. I think that's the basic reason. Although overflow: hidden itself doesn't have that problem, it's convenient the way they've defined it so you can make a parent envelop its floating descendents. "Zoom" is not a CSS property, I have no idea what it means, but it seems to do the job in IE. |
#9
| |||
| |||
|
|
Ben C wrote: snip According to this article, which somebody just posted in another thread: http://www.quirksmode.org/css/clearing.html You can use width: 100%; to do the same job as zoom: 1; 'The width is necessary to trigger "hasLayout" in Explorer Windows (except for 7)' Interesting stuff. |
#10
| |||
| |||
|
|
It's amazing how often this problem comes up (i.e., containers collapsing due to floats being out of the document flow). There needs to be a standard property to do what 'overflow: hidden;' does. |
![]() |
| Thread Tools | |
| Display Modes | |
| |