css-浮动围绕文字效果

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .box {
            /* 内边距不会撑大盒子
            盒子的大小 = 内容的大小 + 内边距的大小

            图片浮动不会压到文字
             */
            box-sizing: border-box;
            padding: 5px;
            width: 300px;
            height: 70px;
            background-color: #eee;
            margin: 0 auto;
        }

        .pic {
            float: left;
            width: 120px;
            height: 60px;
            margin-right: 5px;

        }

        .pic img {
            width: 100%;
            height: 100%;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="pic">
            <img src="./imgs/003.gif" alt="">
        </div>
        热身-巴西迷路阿萨德萨达萨达撒萨达
    </div>
</body>

</html>
posted @ 2025-09-24 09:26  紫川先生  阅读(8)  评论(0)    收藏  举报