css写带边框的三角形

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>DEMO</title>
    <style>
        .demo{
            width: 200px;
            height: 200px;
            /*background-color: #999;*/
            margin: 0 auto;
        }
        .tri{
            display: block;
            width: 20px;
            height: 20px;
            position: relative;
            left: 10px;
            /*border: 1px solid green;*/
        }
        .tri:before,.tri:after{
            content: "";
            display: block;
            position: absolute;
            left: 0;
            top: 0;
            border-width: 10px;
            border-color: transparent transparent red transparent;
            border-style: dashed dashed solid dashed;
        }
        .tri:after{
            margin-top: 1px;
            border-color: transparent transparent white transparent;
        }
        .tri.active:before{
            border-color: transparent transparent green transparent;
        }
    </style>
</head>
<body>
    <div class="demo">
        <span class="tri active"></span>
    </div>
</body>
</html>
上一篇:1.2 容器-container


下一篇:适合初学者的python实际例子