自学内容网 自学内容网

二十一、浮动(2 div)

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>

        <style>
            div:nth-child(1){
                width: 200px;
                height: 200px;
                border: 2px solid red;
                float:left;/*后面元素会占用之前的位置*/
            }
            div:nth-child(2){
                width: 100px;
                height: 100px;
                border: 2px solid blue;
                float: left;
                }
            div:nth-child(3){
                width: 50px;
                height: 50px;
                border: 2px solid green;
                float: left;
                }
            div:nth-child(4){
                width: 50px;
                height: 50px;
                border: 2px solid pink;
                float: both;
                }
        </style>
    </head>
    <body>

        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
    </body>
</html>


原文地址:https://blog.csdn.net/pale_moonlight/article/details/142845844

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!