«

盒子内的布局

MitSeek 发布于 阅读:10 CSS


<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <style>
            .main{
                border: 1px solid red;
                width: 480px;
                overflow: auto;/* 清除子元素的浮动 */
                color: white;
                margin: 0 auto;
                padding: 30px;
                background:-o-linear-gradient(bottom right,red,blue);/* 背景颜色渐变 */
                background: linear-gradient(to bottom right,red,blue);
            }
            div h1{
                text-align: center;
            }
            .box{
                float: left;
                margin-left:30px;
            }
            .box1{
                width:200px;
                text-indent: 2em;/* 首行缩进2个字符 */
            }
            img{
                width: 180px;
                height: 200px;
            }
        </style>
    </head>
    <body>
    <div class="main">
        <h1>一二一</h1>
        <div class="box">
            1
            <div class="box1">1.1</div>
            <div><img src="01.webp" alt="" /></div>
            <div class="box1">1.3</div>
        </div>
        <div class="box">
            2
            <div class="box1">2.1</div>
            <div><img src="02.jpg" alt="" /></div>
            <div class="box1">2.3</div>
        </div>
    </div>
    </body>
</html>

CSS