CSS float an exercise

Source: Internet
Author: User

HTML code:

<body>
<div class= "div01" >div01</div>
<div class= "div02" >
    <div class= " Nei01 ">nei1</div>
    <div class=" nei02 ">nei2</div>
    <div class=" nei03 ">nei3</ div>
    <div class= "nei04" >nei4</div>
    <div class= "nei05" >nei5</div>
    <div class= "nei06" >nei6</div>
    <div class= "nei07" >nei7</div>
    <div class= "nei08" > nei8</div>
    <div class= "nei09" >nei9</div>
    <div class= "nei10" >nei10</div>
    <div class= "nei11" >nei11</div>
    <div class= "nei12" >nei12</div>
    <div class= "nei13" >nei13</div>
    <div class= "nei14" >nei14</div>
</div>
< Div class= "div03" >xuhaitaoxuhaitaoxuhaitaoxuhaitaoxuhaitaoxuhaitaoxuhaitao</div>
</body>

If the CSS settings are as follows:

  <style>
        div01 {
            margin-top:50px;
            width:300px;
            height:200px;
            Background-color:burlywood
        }

        . div02 {
            margin-top:5px;
            width:400px;
            height:400px;
            Background-color:aqua
        }

        . div03 {
            margin-top:5px;
            width:300px;
            height:200px;
            Background-color:thistle;
            Font-size:xx-large;
            Color:fuchsia;
            Word-break:break-all
        }
        . nei01,.nei02,.nei03,.nei04,.nei05,.nei06,.nei07,.nei08,.nei09,.nei10,.nei11,.nei12,.nei13,.nei14{
            margin-top:3px;
            marign:5px;
            width:150px;
            height:50px;
            Background-color:blueviolet;
           Font-size:xx-large;

        }
    </style>

The effect is as follows:

Summary: Although nei9,nei10,nei11,nei12,nei13,nei14 these elements are beyond the bounds of their container (DIV02), because the container div02 is set in height, div03 is laid out in the stream, is not affected by the div02 content beyond the boundary, but the display is very bad, it is recommended not to go beyond the boundary, if the use of Overflow:hidden beyond the boundary will be more than partially hidden, or simply do not set the height, height by the requirements

Below, cancel the height of the div02, as follows:

The effect is as follows:

Summary: Because the div02 does not set the height, oneself actual need how much to decide how much

Next to the above CSS to do a change:

The effect screen is as follows:

Finally added:

FR: Xu Haitao (QQ technology Group: 386476712)

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.