0
点赞
收藏
分享

微信扫一扫

四位定位方法

小安子啊 2022-04-24 阅读 80
htmlcss

 样例:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>哆啦A梦</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        .duo{
            width: 400px;
            height: 380px;
            background-color: pink;
            position: relative;
        }
        .duo div{
            position: absolute;
        }
        .head{
            width: 372px;
            height: 352px;
            background-color: #00b0db;
            border-radius: 48%;
            left: 14px;
            top: 14px;
            position: absolute;
        }
        .face{
            width: 306px;
            height: 230px;
            background-color: #fff;
            border-radius: 45%;
            left: 36px;
            top: 84px;
        }
        .eye{
            width: 85px;
            height: 95px;
            border-radius: 45%;
            background-color: #fff;
            top: 50px;
            left: 93px;
            border: 2px solid #111;
            position: absolute;
        }
        .eye div{
            width: 15px;
            height: 15px;
            background-color: #111;
            left: 56px;
            top: 50px;
            border-radius: 50%;
        }
        .eye2{
            left: 180px;
        }
        .eye2 div{
            left: 14px;
        }
        .bz{
            width: 40px;
            height: 40px;
            background-color: #cb3304;
            border-radius: 45%;
            left: 159px;
            top: 131px;
            border: 2px solid #111;
        }
        .line{
            width: 2px;
            height: 102px;
            background-color: #111;
            left: 184px;
            top: 172px;
        }
        .zui{
            width: 254px;
            height: 254px;
            background-color: transparent;
            border-radius: 50%;
            left: 60px;
            top: 20px;
            border-bottom: 2px solid #111;
        }
    </style>
</head>
<body>
    <div class="duo">
        <div class="head">
            <div class="face"></div>
            <div class="eye eye1">
                <div></div>
            </div>
            <div class="eye eye2">
                <div></div>
            </div>
            <div class="bz"></div>
            <div class="line"></div>
            <div class="zui"></div>
        </div>
    </div>
</body>
</html>

输出结果:

关键是position的运用 

举报

相关推荐

0 条评论