css实现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%);*/    这个方式也可以
            background: linear-gradient(-45deg, transparent 52px, #1853ac 0) top right;

        }
        .box2{
            background: #6e45e2;
            transform: skew(135deg);
        }
        .box2_text {
            /* div斜了会影响里面的文本,所以需要把div斜了,让文本正常,文本就要逆向倾斜,并且包裹文本的元素必须是块级元素 */
            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">加入购物车</div>
        <div class="box2 box">
            <div class="box2_text">支付订单</div>
        </div>
        <div class="box3 box">等待收货</div>
    </div>
</body>
</html>
图片.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容