搜 索

一个看着不错的文章置顶标签效果

  • 259阅读
  • 2022年07月27日
  • 0评论
首页 / 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>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        body {
            background: #f5f5f5;
        }

        .box {
            overflow: hidden;
            position: relative;
            width: 260px;
            height: 150px;
            margin: 100px auto;
            background-color: #fff;
            text-align: center;
        }

        .box span {
            position: absolute;
            top: 10px;
            left: -30px;
            transform: rotate(-50deg);
            width: 90px;
            height: 20px;
            line-height: 20px;
            color: #fff;
            background-color: #fa5b5c;
            font-size: 12px;
        }

        .box span::after {
            content: "";
            position: absolute;
            top: 20px;
            left: 70px;
            border-right: 5px solid #f55b5d;
            border-top: 5px solid #f55b5d;
            border-left: 5px solid transparent;
            border-bottom: 5px solid transparent;
        }

        .box span::before {
            content: "";
            position: absolute;
            top: 20px;
            left: 10px;
            border-left: 5px solid #f55b5d;
            border-top: 5px solid #f55b5d;
            border-right: 5px solid transparent;
            border-bottom: 5px solid transparent;
        }

        .box img {
            width: 247px;
            height: 139px;
            margin-top: 6px;
        }
    </style>
</head>

<body>
    <div class="box">
        <img src="https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/5e7d37251bc04bf48caafe62eae2991e~tplv-k3u1fbpfcp-zoom-crop-mark:1304:1304:1304:734.awebp?"
            alt="">
        <span>置顶</span>
    </div>
</body>

</html>
CSS
评论区
暂无评论
avatar