Several methods to clear floats

php中世界最好的语言
Release: 2018-03-22 11:43:11
Original
2515 people have browsed it

This time I will bring you several methods of clearing floats, and what are the precautions for clearing floats. The following is a practical case, let’s take a look.

html

    <p>
        <p class=&#39;box-left&#39;></p>
        <p class=&#39;box-right&#39;></p>
    </p>
Copy after login

css

.box-left,.box-right{
        width:200px;
        height:200px;
        float: left;
        background: red;
        border:1px solid #333;
    }
Copy after login

First method: .box{clear: box}

Second method:.box{overflow:hidden}

Third method:. box{overflow:auto}

Fourth method:.box:after{ content:""; height:0; visibility:hidden; display:block; clear:both;}.box{ zoom:1;}

The fifth method: .box{height:200px}Set the height

The sixth method: .box{display:table}

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

CSS to draw a red heart

##The difference between display and visibility

Several ways to implement Footer bottom placement in CSS

The above is the detailed content of Several methods to clear floats. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template