HTML serial 48- to clear the floating of two ways in which

First, to clear floating a way

In front of a parent element to set the height, attention: Corporate development can not write, do not write highly height

 

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>D131_ClearFloat</title>

    <style>

        .smallbox1{

            width:100px;

            height:100px;

            background-color: red;

            boder:3px solid black;

            margin:5px;

            float:right;


        }

        .smallbox2{

            width:100px;

            height:100px;

            background-color: red;

            boder:3px solid black;

            margin:5px;


        }

        .smallbox3{

            width:100px;

            height:100px;

            background-color: red;

            boder:3px solid black;

            margin:5px;


        }

        .smallbox4{

            width:100px;

            height:100px;

            background-color: red;

            boder:3px solid black;

            margin:5px;


        }

        .smallbox5{

            width:100px;

            height:100px;

            background-color: red;

            boder:3px solid black;

            margin:5px;


        }

        .smallbox6{

            width:100px;

            height:100px;

            background-color: red;

            boder:3px solid black;

            margin:5px;


        }

        .bigbox1,.bigbox2{

            /*width:400px;*/

            /*width:400px;*/

            background-color: green;

            border:3px black solid;

        }

</style>

</head>

<body>

<div class="bigbox1">

    <div class="smallbox1"></div>

    <div class="smallbox2"></div>

    <div class="smallbox3"></div>

</div>

<div class="bigbox2">

    <div class="smallbox4"></div>

    <div class="smallbox5"></div>

    <div class="smallbox6"></div>

</div>

</body>

</html>

 

Second, remove floating second way

Properties added to the back of clear property

clear attribute values:

none: default values, sorted according to the ordering rules of the floating element (floating left to find floated left and right to find the right float float)

left: Do not look for the front of the left floated elements

right: do not look right in front of the float

both: Do not look for the front of the left floating and floating elements

For example: We do not set the width and height of the big box, big box small box will hold up, but two big boxes will therefore be on one line

 

       .smallbox1{

            width:100px;

            height: 100px;

            float:left;

            background-color: red;

            border:2px solid black;

        }

        .smallbox2{

            width:100px;

            height: 100px;

            float:left;

            background-color: red;

            border:2px solid black;

        }

        .smallbox3{

            width:100px;

            height: 100px;

            float:left;

            background-color:blue;

            border:2px solid black;

        }

        .smallbox4{

            width:100px;

            height: 100px;

            float:left;

            background-color: blue;

            border:2px solid black;

        }

    </style>

</head>

<body>

<div class="bigbox1">

    <div class="smallbox1"></div>

    <div class="smallbox2"></div>

</div>

<div class="bigbox2">

    <div class="smallbox3"></div>

    <div class="smallbox4"></div>

</div>

</body>

 

We use the clear property on the third small box, so that you can separate line of the (fourth would not, because we want a third next to fourth), only the third small box code modify the code

        .smallbox3{

            clear:left;

            width:100px;

            height: 100px;

            float:left;

            background-color:blue;

            border:2px solid black;

        }

Precautions: margin property fails, the failure is not the way the next time we talk.

Third, the source code:

D131_ClearFloat.html

D132_CLearAttribute.html

address:

https://github.com/ruigege66/HTML_learning/blob/master/D131_ClearFloat.html

https://github.com/ruigege66/HTML_learning/blob/master/D132_CLearAttribute.html

2.CSDN: https: //blog.csdn.net/weixin_44630050 (Xi Jun Jun Moods do not know - Rui)

3. Park blog: https: //www.cnblogs.com/ruigege0000/

4. Welcomes the focus on micro-channel public number: Fourier transform, personal account only for technical exchanges, backstage reply "gifts" big data acquisition Java Learning Video Package

 

 

Guess you like

Origin www.cnblogs.com/ruigege0000/p/11817220.html