上代码如下:

 

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>网页布局</title>
    <style>

        #main {
            background-color: pink;
            width: 600px;
            height: 400px;
            /*float: left;*/

        }
        #div1 {
            width:100px;
            height: 200px;
            background-color: orange;
            margin-top: 25%;
            float: left;
            vertical-align: middle;
        }

       #div2 {
            width:400px;
            height: 100px;
            background-color: brown;
            margin-top: 25%;
            float: left;
        }
       #div3 {
            width:100px;
            height: 200px;
            background-color: darkgreen;
            margin-top: 25%;
            float: right;
        }

       #div4 {
            width:400px;
            height: 100px;
            background-color: darkblue;
            float: left;
        }

        .content {
            font-size: 36px;
            font-family: "Microsoft YaHei UI Light" "Arial Black";
        }
    </style>
</head>
<body>
    <div id="main">
        <div id="div1"><!--黄色--></div>
        <div id="div2"><!--棕色--></div>
        <div id="div3"><!--绿色--></div>
        <div id="div4"><!--蓝色--></div>
    </div>
    <div class="content">通过浮动来实现网页布局</div>
    <div class="content">Earth Square</div>
</body>
</html>

 

 

 

 

网页布局

通过浮动来实现网页布局
Earth Square
posted on 2018-10-10 20:31  yellwonfin  阅读(77)  评论(0)    收藏  举报