Welcome to Eyes on FF!
>>> Click here to download Final Fantasy Ringtones
Oh no!
 

Post New Thread  Reply
 
LinkBack Thread Tools
Samuraid
Administrator
Ominous Wanderer
Samuraid's Avatar
#1
Default CSS question (problem)

Hello EoFF CSS gurus,
Perhaps you can help me understand what I'm doing incorrectly here.

Here's a simple HTML page that outlines the problem. Check out the source code specifically.

I need to know why the <div> tags are behaving this way with this CSS.

Thanks a bunch for any insight you can provide!
Attached Images
File Type: png problem.png (7.6 KB, 14 view)
Attached Files
File Type: html problem.html (1.3 KB, 7 view)
Old 08-06-2008, 12:08 AM
Reply With Quote
Samuraid is offline  
Balzac
Balzac's Avatar
Location: Hangcaster, England
Default

The div tags aren't working right because you have the "float" command in them.

As for your other problem, I have no idea.
Old 08-06-2008, 12:32 AM
Reply With Quote
Balzac is offline  
Samuraid
Administrator
Ominous Wanderer
Samuraid's Avatar
Default

Problem #1 is solved. A web-developer friend pointed out that adding this before closing the blue div would solve the problem:
Code:
<div style="clear: both;"></div>
The second problem he said was a padding issue. I'm still a bit unsure on that one.

EDIT: Problem #2 solved by trial and error. It's not a padding issue. Instead, turning off the borders on the red and green divs fixes the problem.

I guess that about wraps that up. Thanks for the suggestions.
I'll leave this open if anyone has anything to add.
Old 08-06-2008, 12:41 AM
Reply With Quote
Samuraid is offline  
o_O
Site Staff
nerd
o_O's Avatar
Location: New Zealand
Default

Ok, for problem one:
When the height of the parent div is evaluated, it takes into consideration the height/content of any child element in the normal flow of the page. Since floated elements are removed from the normal flow to allow other content to flow around them, the div disregards their heights, even though they are its children. My solution is either to not float one of the child divs, leaving it in the normal flow and forcing the parent div to stretch to its height, or adding a non-floated block element inside the parent div with the "clear" attribute.

And for problem two:
I'm fairly certain this has to do with the way IE and Firefox interpret the "width" attribute of block elements. For clarity's sake I'll just point out that a block element is always rendered with a line break immediately following unless the CSS "display: inline;" is explicitly used.
Anyway, with block elements, IE considers the width property to include the internal space of the element (i.e. the screen space taken up by the block's content) as well as the external space taken up by margins, padding, spacing and borders. In Firefox, these four attributes are not included in the "width" of the element (and this is the correct way ).
Upon closer inspection, you'll notice that there's a four-pixel overlap in firefox, and with one-pixel borders.... So my solution in this case is to set the width of one or both child divs to 49%, which produces (almost) no discernable difference between IE and Firefox.
Old 08-06-2008, 01:09 AM
Reply With Quote
o_O is offline  
Yamaneko
..a Russian mountain cat.
Yamaneko's Avatar
Location: Los Angeles, CA
Default

Get a room!
Old 08-06-2008, 01:28 AM
Reply With Quote
Yamaneko is offline  
Samuraid
Administrator
Ominous Wanderer
Samuraid's Avatar
Default

Originally Posted by o_O ^
Ok, for problem one:
When the height of the parent div is evaluated, it takes into consideration the height/content of any child element in the normal flow of the page. Since floated elements are removed from the normal flow to allow other content to flow around them, the div disregards their heights, even though they are its children. My solution is either to not float one of the child divs, leaving it in the normal flow and forcing the parent div to stretch to its height, or adding a non-floated block element inside the parent div with the "clear" attribute.

And for problem two:
I'm fairly certain this has to do with the way IE and Firefox interpret the "width" attribute of block elements. For clarity's sake I'll just point out that a block element is always rendered with a line break immediately following unless the CSS "display: inline;" is explicitly used.
Anyway, with block elements, IE considers the width property to include the internal space of the element (i.e. the screen space taken up by the block's content) as well as the external space taken up by margins, padding, spacing and borders. In Firefox, these four attributes are not included in the "width" of the element (and this is the correct way ).
Upon closer inspection, you'll notice that there's a four-pixel overlap in firefox, and with one-pixel borders.... So my solution in this case is to set the width of one or both child divs to 49%, which produces (almost) no discernable difference between IE and Firefox.
Hats off to you, good sir. You made the solution make sense.
Old 08-08-2008, 07:44 AM
Reply With Quote
Samuraid is offline  
Post New Thread  Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:28 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.0.0
Copyright ©2000 - 2007, Eyes on Final Fantasy.
Sean Robinson Design