CSS魔法旋转卡片

本文分享了一种利用CSS3动画和3D变换制作的简易魔法卡旋转效果,通过代码展示了如何创建一个卡片盒围绕中心无限旋转,并且包含前后两面的切换。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


前言

最近也很久没更新了,带大家看看我之前用CSS写的简易魔法卡旋转效果。
在这里插入图片描述


一、首先上效果图

在这里插入图片描述
在这里插入图片描述

大家可以在gitee中查看效果图,点击访问

二、代码如下

<!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>Document</title>
    <style>
    *{
        padding: 0;
        margin: 0;
    }
    body{
        display: flex;
        height: 100vh;
        justify-content: center;
        align-items: center;
        background-color: black;
        /* background: url("img/bbbb.jfif"); */
    }
    .fabox{
        position: absolute;
        width: 700px;
        height: 700px;
        animation: fa;
        animation-duration: 50s;
        animation-timing-function:cubic-bezier(0.6, 0.6, 0, 0.01);
        animation-iteration-count: infinite;
        background: url("img/666.png") no-repeat center;
        background-size: 100% 100%;
        flex-basis: 700px;
        transform:rotate(0deg);
    }
    .card_box{
        position:relative;
        left: 230px;
        top: 150px;
        height:425px;
        width: 250px;
        animation: card_box;
        animation-duration: 10s;
        animation-timing-function:cubic-bezier(0.2, 0.56, 0.79, 0.48);
        animation-iteration-count: infinite;
        transform-style: preserve-3d;
        box-shadow: 0px 0px 14px 1px rgb(133 133 133);;
        transform:rotateX(0deg) rotateY(360deg)
    }
    .card_back{
        position:absolute;
        display: inline-block;
        height: 100%;
        width: 100%;
        background: url("img/back.jpg") no-repeat center;
        background-size: 100% 100%;
        transform:translateZ(1px);
        border-radius: 5px;
        box-shadow: 0px 0px 1px 1px rgba(136, 136, 136, 0.5);
    }
    .card_style{
        position:absolute;
        display: inline-block;
        height: 100%;
        width: 100%;
        background: url("img/q2.png") no-repeat center;
        background-size: 100% 100%;
        border-radius: 5px;
        box-shadow: 0px 0px 1px 1px rgba(136, 136, 136, 0.5);
    }
    .bbox{
        position: relative;
        perspective: 800px;
        height: 700px;
        width: 700px;
    }
    @keyframes fa{
        0%{
            transform:rotate(0deg);
        }
        100%{
            transform:rotate(360deg);
        }
    }
    @keyframes card_box{
        0%{
            transform:rotateX(0deg) rotateY(360deg)
        }
        100%{
            transform:rotateX(0deg) rotateY(0deg)
        }
    }
    </style>
</head>
<body>
    <div class="bbox">
    <div class="fabox"></div>
    <div class="card_box">
        <span class="card_back"></span>
        <span class="card_style"></span>
    </div>
</div>
 
</body>
</html>

总结

本次主要是使用了了CSS的3d效果,和旋转效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值