TypechoJoeTheme

拾光°の博客

登录
用户名
密码
/
注册
用户名
邮箱
标签搜索

css三角,scc丝带

2022-01-05
/
0 评论
/
181 阅读
/
正在检测是否收录...
01/05

思路1 利用css三角

思路是用两个css三角一大一小,小的压住大的丝带就出来了,然后文字逆时针旋转45度就好了
<!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>
</head>
<style>
    /* 案例1 */
    /* 案例1 */
    /* 案例1 */

    .main {
        position: relative;
        width: 100px;
        height: 50px;
        margin: 100px auto 100px;
        box-shadow: 1px 1px 30px #ccc;
    }

    /* 利用css三角   做一个大的蓝色三角 */
    .bigTriangle {
        height: 0;
        width: 0;
        border-top: 50px solid rgb(52, 139, 238);
        border-right: 50px solid rgb(52, 139, 238);
        border-bottom: 50px solid transparent;
        border-right: 50px solid transparent;
    }

    /* 利用css三角 做一个小的白色三角   这就把 梯形显示出来了 */
    .smallTriangle {
        position: absolute;
        top: 0;
        left: 0;
        height: 0;
        width: 0;
        border-top: 25px solid #fff;
        border-right: 25px solid #fff;
        border-bottom: 25px solid transparent;
        border-right: 25px solid transparent;
    }

    /* 斜的文字你时针旋转45度 */
    .title {
        position: absolute;
        top: 8px;
        left: -1px;
        transform: rotateZ(-45deg);
        width: 42px;
        color: #fff;
        font-size: 12px;
    }
</style>

<body>

    <div class="main">
        <!-- 大三角 -->
        <div class="bigTriangle">
            <!-- 小三角 -->
            <div class="smallTriangle"></div>
            <!-- 文字 -->
            <span class="title">进行中</span>
        </div>
    </div>

</body>

</html>

效果如下

思路二 直接div旋转

直接把一个div旋转 然后overflow: hidden;就好了

<!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>
</head>
<style>
    .main-2 {
        position: relative;
        margin: 0 auto;
        height: 200px;
        width: 500px;
        /* 隐藏多出的div */
        overflow: hidden;
        box-shadow: 1px 1px 30px #ccc;
    }

    .triangle {
        position: absolute;
        top: 4.6em;
        left: -3.4em;
        width: 18em;
        height: 2em;
        overflow: hidden;
        background-color: #dc3545;
        box-sizing: content-box;
        line-height: 2em;
        color: #fff;
        font-size: 1em;
        text-align: center;
        text-decoration: none;
        font-weight: bold;
        transform: rotate(-45deg);
    }
</style>

<body>

    <div class="main-2">
        <div class="triangle">css丝带</div>
    </div>

</body>

</html>

朗读
赞 · 0
版权属于:

拾光°の博客

本文链接:

https://www.blog.lzlj.top/index.php/archives/28/(转载时请注明本文出处及文章链接)

评论 (0)
24 文章数
421 评论量
IP信息

人生倒计时

今日已经过去小时
这周已经过去
本月已经过去
今年已经过去个月