css實(shí)現(xiàn)div斜邊

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Title</title>
    <style>
        .box {
            width: 20%;
            height: 50px;
            color: #fff;
            font-size: 22px;
            text-align: center;
            line-height: 50px;
            cursor: pointer;
            margin-left: -45px;
        }
        .box1{
            /*clip-path: polygon(0 0, 76% 0, 24% 100%, 0% 100%);*/    這個(gè)方式也可以
            background: linear-gradient(-45deg, transparent 52px, #1853ac 0) top right;

        }
        .box2{
            background: #6e45e2;
            transform: skew(135deg);
        }
        .box2_text {
            /* div斜了會(huì)影響里面的文本,所以需要把div斜了,讓文本正常,文本就要逆向傾斜,并且包裹文本的元素必須是塊級(jí)元素 */
            transform: skew(-135deg);
        }
        .box2:hover {
            transform: scale(0.95) skew(135deg);
            transition: all 0.5s;
        }
        .box3{
            background: linear-gradient(135deg, transparent 52px, #1853ac 0) top right;
        }
        .box1:hover,.box3:hover{
            transition: all 0.5s;
            transform: scale(0.95);
        }
 </style>
</head>
<body>
    <div style="display: flex;padding: 50px;">
        <div class="box1 box">加入購(gòu)物車(chē)</div>
        <div class="box2 box">
            <div class="box2_text">支付訂單</div>
        </div>
        <div class="box3 box">等待收貨</div>
    </div>
</body>
</html>
圖片.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容