A good way to clear the float inside the UL Li and make UL adaptive height

Source: Internet
Author: User

Sometimes you will encounter the UL Li List of things will be used to float, this time the height of the UL will not be open, how to do?

1) The most stupid way is to set the height of UL, but this method is very rigid, highly not adaptive

2) Once I tried to add a clear floating div in the UL, this can achieve the effect, but this practice is wrong, does not conform to the specification, so absolutely can not write this.

<ul>

<li></li>

<div style= "Clear:both" ></div>

</ul>

Can't write like this!

3) One of the best ways to do this is: add it to the UL tag: Overflow:hidden;clear:both; These two styles can be properly made to keep the UL height open.

<ul style= "Overflow:hidden;clear:both;" >

<li></li>

</ul>

This can also be used for any DIV element that is highly adaptive after the internal content floats.

This method I feel more than add a <div style= "Clear:both" ></div> a little better

A good way to clear the float inside the UL Li and make UL adaptive height

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.