ul和li实现翻书动画效果

HTML与CSS实现翻书动画
本文介绍如何使用HTML的ul和li元素结合CSS的perspective和rotateY属性,创建逼真的翻书动画效果。通过避免li元素间的间距并巧妙运用CSS动画,实现了翻页的视觉体验。

来看看HTML部分:

由于li是inline-block元素,所有没有写li的闭合,写了的话每个li之间会有4px的间距,不写浏览器也会自动补全。

CSS部分

    body {
        text-align: center;
    }
    
    ul {
        background: gray;
        width: 100%;
        padding: 20px;
        -webkit-perspective: 200;
    }
    
    li {
        list-style: none;
        height: 50px;
        width: 100px;
        padding: 0;
        margin: 0;
        display: inline-block;
        background: white;
        border-radius: 2px;
    }
    
    .anim {
        animation: anim 1s infinite;
        width: 100px;
        margin-left: -100px;
        background: white
    }
    
    @keyframes anim {
        to {
            transform: rotateY(-360deg);
        }
    }
    
    .anim2 {
        animation: anim2 1s infinite;
        width: 100px;
        margin-left: -100px;
        background: white
    }
    
    @keyframes anim2 {
        25% {
            transform: rotateY(0deg);
        }
        to {
            transform: rotateY(-360deg);
        }
    }

这个动画效果的实现,主要靠是perspective + rotateY的应用,


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值