京东css三角形做法

<!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>京东css三角做法</title>
    <style>
        .sj {
            position: absolute;
            /* -20是border的两倍 */
            top: -20px;
            right: 10px;
            width: 0;
            height: 0;
            border: 10px solid transparent;
            border-bottom-color: pink;
            /* 为了照顾兼容性 */
            line-height: 0;
            font-size: 0;
        }
        
        .box {
            position: relative;
            width: 100px;
            height: 100px;
            background-color: gray;
            margin: 100px auto;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="sj"></div>
    </div>

</body>

</html>
posted @ 2021-03-26 14:52  ice猫猫3  阅读(88)  评论(0编辑  收藏  举报