CSS floating comparison in IE7, FireFox, and IE8

Source: Internet
Author: User
IE7: <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
Transitional. dtd ">
<Html>
<Head>
<Meta http-equiv = "X-UA-Compatible" content = "IE = EmulateIE7"/>
<Title> </title>
</Head>
<Body>
<Div style = "width: 600px; height: 300px; background-color: Black; float: left;"> </div>
<Div style = "width: 600px; height: 300px; background-color: Yellow; float: right;"> </div>
<Div style = "background-color: Green; height: 100px;"> aa </div> <! -- In IE7, The div is not hidden below the floating element.
The clear floating element is a placeholder for the div -->
<Table style = "background-color: Red; height: 10px; width: 10px;"> <! -- Floating elements in IE7 hold a placeholder for the table -->
<Tr>
<Td>
</Td>
</Tr>
</Table>
<Span style = "clear: both;"> <! -- Non-block-level elements in IE7 can clear floating -->
456
</Span>

</Body>
</Html>

FireFox/IE8 <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
Transitional. dtd ">
<Html>
<Head>
<Meta http-equiv = "X-UA-Compatible" content = "IE = EmulateIE8"/>
<Title> </title>
</Head>
<Body>
<Div style = "width: 600px; height: 300px; background-color: Black; float: left;"> </div>
<Div style = "width: 600px; height: 300px; background-color: Yellow; float: right;"> </div>
<Div style = "background-color: Green; height: 100px;"> aa </div> <! -- In IE8, The div is hidden below the floating element, indicating that the floating Element
Div is not placeholder, But aa is crowded in the middle. It indicates that floating elements must be placeholder for non-block-level elements in div -->
<Table style = "background-color: Red; height: 10px; width: 10px;"> <! -- Floating elements in IE8 occupy space on the table, which is better indicated in IE8 and
Floating elements in FireFox are not placeholder only for div -->
<Tr>
<Td>
</Td>
</Tr>
</Table>
<Span style = "clear: both;"> <! -- Float cannot be cleared for non-block-level elements in IE8 -->
456
</Span>
<P style = "clear: both;"> <! -- In IE8, block-level elements can be cleared. -->
789
</P>
</Body>
</Html>

Note the following:
The display: inline of div disappears completely.

In IE and FireFox: <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
Transitional. dtd ">
<Html>
<Head>
<Meta http-equiv = "X-UA-Compatible" content = "IE = EmulateIE8"/>
<Title> </title>
</Head>
<Body>
<Div style = "background-color: Maroon; width: 60px; height: 60px; float: left;">

</Div> <! -- Floating elements reduce part of the block-level elements that follow them. For example, table t1 is a block-level element, after div float, t1 is not full on the right side of div, but only full on the right side of div -->
<Table id = "t1" style = "background-color: Green; width: 60px; height: 60px;">
<Tr>
<Td>

</Td>
</Tr>
</Table>
Row 2
</Body>
</Html>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.