Web_CSS3_3d卡片旋转【案例】

卡片旋转案例

<body>
<ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
    <li>6</li>
</ul>
</body>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            /*3D旋转就是在父元素中添加一个perspective属性a*/
            perspective: 600px;
        }
        ul{
            list-style: none;
            width: 400px;
            height: 500px;
            margin: 50px auto;
            position: relative;
            /*border: 1px solid #000;*/
            transform: rotateX(-45deg);
            /*要想使本身具有3d效果的元素的子元素也可以3d旋转 那么就要给当前父元素添加下面属性 transform-style:preserve-3d*/
            transform-style:preserve-3d;
        }
        ul>li{
            width: 100px;
            height: 200px;
            line-height: 200px;
            color: #ffffff;
            background-color: hotpink;
            text-align: center;
            font-size: 30px;
            position: absolute;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            margin: auto;
        }
        ul>li:nth-child(1){
            transform: rotateY(0deg) translateZ(200px);
        }
        ul>li:nth-child(2){
            transform: rotateY(60deg) translateZ(200px);
        }
        ul>li:nth-child(3){
            transform: rotateY(120deg) translateZ(200px);
        }
        ul>li:nth-child(4){
            transform: rotateY(180deg) translateZ(200px);
        }
        ul>li:nth-child(5){
            transform: rotateY(240deg) translateZ(200px);
        }
        ul>li:nth-child(6){
            transform: rotateY(300deg) translateZ(200px);
        }
    </style>

设置样式后的状态

hover状态下

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值