纯css实现信封效果

纯css实现信封效果

<body>
    <div id="dialog">
        <div id="envelope">
            <div id="message">你好,世界!</div>
            <div class="top"></div>
            <div class="bottom"></div>
            <div class="left"></div>
            <div class="right"></div>
            <div class="close">
                <!---关闭按钮 悬浮按钮 加阴影 字体图标-->
            </div>
        </div>
    </div>
</body>
		:root {
            --vw: 500px;
            --vh: 308px;
            --border-width: 10px;
            --border-color1: #062757;
            --border-color2: #e4c8a1;
            --border-color3: #9f0607;
            --inner-bgcolor: #e9ca8a;
            --lr-bgcolor: #ead2ac;
            --top-bgcolor: #e5d4b8;
            --bottom-bgcolor: #e5c9a2;
        }

        body {
            font-family: "luck";
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            overflow: hidden;
        }

        #dialog {
            width: 100vw;
            height: 100vh;
            background-color: rgba(0, 0, 0, 0.4);
            position: fixed;
            top: 0;
            left: 0;
            overflow: hidden;
        }

        #envelope {
            width: var(--vw);
            height: var(--vh);
            /*居中*/
            margin: 350px auto;
            box-sizing: border-box;
            background-color: var(--inner-bgcolor);
            position: relative;
            /* overflow: hidden; */
            animation: slideInX 4s cubic-bezier(0.36, 0, 0.64, 1) -2s forwards, slideInY 4s cubic-bezier(0.36, 0, 0.64, 1) forwards;
        }

        .close {
            position: absolute;
            right: -100px;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            background-color: #fff;
            z-index: 3;
        }

        @keyframes slideInY {
            0% {
                top: -800px;
                transform: rotate(45deg);
            }

            100% {
                top: 0px;
                transform: rotate(0deg);
            }
        }

        @keyframes slideInX {
            0% {
                left: -800px;
            }

            100% {
                left: 0px;
            }
        }

        .bottom,
        .top {
            position: absolute;
            left: 0;
            width: var(--vw);
        }

        .bottom {
            bottom: 0;
            height: 230px;
            -webkit-clip-path: polygon(50% 42%, 0% 100%, 100% 100%);
            clip-path: polygon(50% 42%, 0% 100%, 100% 100%);
            background-color: var(--bottom-bgcolor);
            z-index: 2;
        }

        .top {
            top: 0;
            height: 215px;
            background-color: var(--top-bgcolor);
            -webkit-clip-path: polygon(53% 81%, 100% 0, 0 0);
            clip-path: polygon(50% 120%, 100% 0, 0 0);
            z-index: 3;
            transform-origin: top;
            animation: open 2s ease-in-out 4s forwards;
        }

        .left,
        .right {
            position: absolute;
            top: 0;
            width: var(--vh);
            height: var(--vh);
            background-color: var(--lr-bgcolor);
            z-index: 1;
        }

        .left {
            left: 0;
            -webkit-clip-path: polygon(100% 100%, 0 0, 0 100%);
            clip-path: polygon(100% 100%, 0 0, 0 100%);
        }

        .right {
            right: 0;
            -webkit-clip-path: polygon(100% 100%, 100% 0, 0 100%);
            clip-path: polygon(100% 100%, 100% 0, 0 100%);
        }

        /*封边条纹*/
        .bottom::before,
        .top::before,
        .right::before,
        .left::before {
            position: absolute;
            content: "";
            display: block;
            background-image: repeating-linear-gradient(-45deg, var(--border-color1) 0, var(--border-color1) 25px, var(--border-color2) 25px, var(--border-color2) 50px, var(--border-color3) 50px, var(--border-color3) 75px, var(--border-color2) 75px, var(--border-color2) 100px);
        }

        .bottom::before,
        .top::before {
            width: var(--vw);
            height: var(--border-width);
            left: 0;
        }

        .bottom::before {
            bottom: 0;
        }

        .top::before {
            top: 0;
            --border-color2: #e5d4b8;
            animation: openBorder 2s ease-in-out 4s forwards;
            transform-origin: top;
        }

        .left::before,
        .right::before {
            top: 0;
            width: var(--border-width);
            height: var(--vw);
            --border-color2: #ead2ac;
        }

        .left::before {
            left: 0;
        }

        .right::before {
            right: 0;
        }

        @keyframes open {
            80% {
                z-index: 3;
            }

            100% {
                transform: rotateX(-180deg);
                background-color: rgba(233, 202, 138, 1);
                clip-path: polygon(50% 90%, 100% 0, 0 0);
                z-index: -1;
            }
        }

        @keyframes openBorder {
            100% {
                transform: rotateX(-180deg);
                opacity: 0;
            }
        }

        /*信纸*/
        #message {
            font-family: 'luck';
            position: absolute;
            top: 50px;
            left: 50px;
            transform: rotate(5deg);
            width: 390px;
            height: 200px;
            background-color: #fff;
            animation: rise 1s ease-in-out 6s forwards;
            z-index: 0;
        }

        @keyframes rise {

            /*纸张上升*/
            100% {
                height: 450px;
                top: -230px;
                transform: rotate(-10deg);
            }
        }

clip-path永远的神!!!附上生成工具

另外常用工具:
奇形怪状border-radius生成工具
拟态按钮生成工具

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值