使用CSS3伪类和圆角实现安卓图标

使用CSS3伪类和圆角实现安卓图标

效果图

在这里插入图片描述

知识点

  • 伪类E::before和E::after
  • 圆角border-radius

代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .icon_box{width:300px;height: 300px;margin:0 auto;border:1px solid #ececec;padding:10px;}
        .an_header{position:relative;width:100px;height: 50px;margin:0 auto;background-color: darkgreen;border-radius: 100px 100px 0 0;margin-bottom: 5px;}
        .an_header::before,.an_header::after{
            content:'';
            background-color: #ffffff;
            position: absolute;
            top:25px;
            width:10px;
            height: 10px;
            border-radius: 50%;
        }
        .an_header::before{left:26px;}
        .an_header::after{right:26px;}
        .an_body{position:relative;width:100px;height: 100px;background-color: darkgreen;margin:0px auto;border-radius: 0 0 10px 10px;}
        .an_body::before,.an_body::after{
            content:'';
            position: absolute;
            width:15px;
            height: 70px;
            top:10px;
            background: darkgreen;
            border-radius: 5px;
        }
        .an_body::before{left:-20px}
        .an_body::after{right:-20px}
        .an_footer{position:relative;width:100px;height: 100px;background-color: #ffffff;margin:0px auto;border-radius: 0 0 10px 10px;}
        .an_footer::before,.an_footer::after{
            content:'';
            position: absolute;
            width:15px;
            height: 70px;
            background: darkgreen;
            border-radius:0px 0px 5px 5px;
        }
        .an_footer::before{left:20px}
        .an_footer::after{right:20px}
    </style>
</head>
<body>
    <main>
        <div class="icon_box">
            <div class="an_header"></div>
            <div class="an_body"></div>
            <div class="an_footer"></div>
        </div>
    </main>
</body>
</html>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值