搜索
热搜: 活动 交友 discuz
查看: 6|回复: 0

马黑黑《纯CSS实现卡片正背两面翻转》

[复制链接]
  • TA的每日心情
    开心
    昨天 15:36
  • 签到天数: 506 天

    连续签到: 1 天

    [LV.9]以坛为家II

    581

    主题

    1508

    回帖

    1万

    积分

    社区管理员

    积分
    14796

    最佳新人活跃会员热心会员推广达人宣传达人灌水之王突出贡献优秀版主荣誉管理

    发表于 昨天 21:34 | 显示全部楼层 |阅读模式
    <style>
        /* body创建景深 :800px */
        body {
            font-size: 2em;
            perspective: 800px;
        }
        /* 容器 :提供3d场景 */
        .pa {
            width: 460px;
            height: 200px;
            transform-style: preserve-3d;
            margin: auto;
            margin-top: 200px;
            position: relative;
        }
        /* 子元素做3d转换 */
        .son {
            width: 100%;
            height: 100%;
            background: linear-gradient(45deg, lightblue, beige);
            box-shadow: 2px 2px 16px rgba(0, 0, 0, .25);
            backface-visibility: hidden; /* 背面朝向观察者时不可见 */
            /*transform: rotate3d(0, 0, 0, 0);*/
            transition: transform 1.2s;
            display: grid;
            place-items: center;
            position: absolute;
        }
        /* 第二个子元素背对观察者(注意角度为负数以确保转向衔接)*/
        .son:nth-of-type(2) {
            transform: rotate3d(0, 1, 0, -180deg);
        }
        /* 容器鼠标滑入 :第一个子元素背对观察者 */
        .pa:hover .son:nth-of-type(1) {
            transform: rotate3d(0, 1, 0, 180deg);
        }
        /* 容器鼠标滑入 :第二个子元素正对观察者 */
        .pa:hover .son:nth-of-type(2) {
            transform: rotate3d(0, 0, 0, 0deg);
        }
    </style>
    
    <div class="pa">
        <div class="son">恭喜您中奖啦!</div>
        <div class="son">中奖金额 :¥6666.66</div>
    </div>
    
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|小黑屋|纳兰音画网 ( 蜀ICP备2021011087号-1 )

    GMT+8, 2026-8-30 13:16 , Processed in 0.078893 second(s), 22 queries .

    Powered by Discuz! X3.5

    © 2001-2020 Comsenz Inc.

    快速回复 返回顶部 返回列表