Optimal method for clearing floating in web design

Source: Internet
Author: User

Overflow can also be used to clear the floating method. It is really easy to add the overflow attribute to the label to clear the floating.
CSS code:
Ul {
List-style: none;
Height: auto;
Margin: 0; p
Adding: 0;
Background-color: #436973;
}
Li {
Float: left;
Width: 80px;
Height: 80px;
Background-color: # 83B1DF;
}
. Demo {
Clear: both;
Border: 1px solid # FF00FF;
Margin-bottom: 5px;
}
. Overflow {
Overflow: auto;
Zoom: 1;
Background-color: #43FF73;
}
Ul {
List-style: none;
Height: auto;
Margin: 0;
Padding: 0;
Background-color: #436973;
}
Li {
Float: left;
Width: 80px;
Height: 80px;
Background-color: # 83B1DF;
}
. Demo {
Clear: both;
Border: 1px solid # FF00FF;
Margin-bottom: 5px;
}
. Overflow {
Overflow: auto;
Zoom: 1;
Background-color: #43FF73;
}
HTML code:
Complete Demo
Here, zoom is prepared for IE6.
Complete Demo
Note: If you forget a very important item, not all overflow attributes can have the same effect. For example, the visible attribute can only work for IE. For example, see Demo2.
In this case, there is a problem. If there is a height, and the content exceeds the height, the definition of auto or hidden may have some undesirable effects. Here is a solution: For IE of IE6 and earlier versions, the height can be defined directly; for IE7, FF, OP, min-height can be defined.
CSS code:
Overflow
{
Height: auto;
_ Height: 200px;
Min-height: 200px;
Verflow: auto;
Zoom: 1;
_ Overflow: visible;
}

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.