Clear DIV float-use: after

Source: Internet
Author: User
Feature: you do not need to add a clear DIV.
: After (pseudo object)-set the content after the object, which is usually used with content. IE does not support this pseudo object, not supported by Ie browsers, so it does not affect IE/WIN browsers.
CSS. wrapfix: after {
Content :".";
Display: block;
Height: 0;
Clear: both;
Visibility: hidden;
}
Set display: block; apply to: after element. Because the default value of display is "inline", the clear feature cannot be received, and the height of the clear container is set to zero, height: 0 ;, visibility is hidden. this is not cleared. non-Ie browsers cannot see the background and border of wrap.
Run code box
<! 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">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = utf-8"/>
<Title> clear floating -- use: after -- Clearing </title>
<Style type = "text/css">
<! --
*{
Padding: 0;
Margin: 0;
}

Body {
Font: 85%/140% Arial, Helvetica, sans-serif;
Padding: 10px 0;
Text-align: center;
}

. Wrap {
Border: 1px solid #999999;
Margin: 0 auto;
Width: 762px;
Width: 760px;
Background: # ECECEC;
Text-align: left;
}

. Wrapfix: after {
Content :".";
Display: block;
Height: 0;
Clear: both;
Visibility: hidden;
}
# Sidel {
Float: left;
Width: 160px;
}

# Sider {
Float: right;
Width: 600px;
Background: # F9F9F9;
}

P, pre, em {
Padding: 10px;
}
-->
</Style>
</Head>
<Body>
<Div class = "wrap">
<Div id = "sider">
<P> clear floating -- use: after </p>
<Em> This is a non-floating. Non-Ie
The browser cannot see the background and border of wrap. </em>
<P> Feature: You do not need to add a clear DIV. </p>
<P>: after (pseudo object) -- set the content after the object, which is usually used with content. IE does not support this pseudo object, not Ie
1st 2 3 pages

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.