纯css3的网站轮播图animation练习2

复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        body{
            width: 100vw;
            height: 100vh;
            display: grid;
        }
        main{
            width: 300px;
            height: 300px;
            display: grid;
            justify-self: center;
            align-self: center;
            overflow: hidden;
            position: relative;
        }
        section{
            width: 1200px;
            height: 300px;
            animation-name: yd;
            animation-duration: 8s;
            animation-iteration-count: infinite;
            display: flex;
            flex-direction: row;
            animation-timing-function: steps(4,end);
            position: relative;
            z-index: 88;
        }
        section:hover,
        section:hover+ul::after{
            animation-play-state: paused;
        }
        div{
            width: 300px;
            background: yellow;
            border: solid 1px #000;
            box-sizing: border-box;
            text-align: center;
            position: relative;
            overflow: hidden;
        }
        ul{
            width: 120px;
            background: rgba(0, 0, 0, 0.5);
            display: flex;
            flex-direction: row; 
            position: absolute;
            bottom:0;
            right: 0;
            z-index: 99;
     
        }
        ul li{
            width: 30px;
            height: 30px;
            line-height: 30px;
            text-align: center;
            list-style:none;
            color:#fff;
            border: 1px solid #fff;
        }
        ul::after{
            content: '';
            width: 30px;
            height: 30px;
            background: orange;
            animation-name: num;
            animation-duration: 8s;
            animation-timing-function: steps(4,end);
            animation-iteration-count: infinite;
            position: absolute;
            left: 0;
            top: 0;
            z-index: -1;
        }
        @keyframes yd {
            to{
                transform: translateX(-1200px);
            }
        }
        @keyframes num {
            to{
                transform: translateX(120px);
            }
        }
 
        img{
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
    <main class="main">
        <section>
            <div><img src="images/1.png" alt=""></div>
            <div><img src="images/2.png" alt=""></div>
            <div><img src="images/3.png" alt=""></div>
            <div><img src="images/4.png" alt=""></div>
        </section>
        <ul>
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>      
        </ul>
    </main>
        
</body>
</html>
相关推荐
RealizeInnerSelf丶3 分钟前
Web 网页如何唤起本地 Windows 应用并传递参数(含 Electron 自动注册 + 手动配置指南)
前端·windows
IT_陈寒11 分钟前
Redis 性能优化实战:5个被低估的配置项让我节省了40%内存成本
前端·人工智能·后端
chilavert31812 分钟前
技术演进中的开发沉思-261 Ajax:动画优化
前端·javascript·ajax
尘心cx15 分钟前
前端-APIs-day3
开发语言·前端·javascript
烂不烂问厨房29 分钟前
前端自适应布局之等比例缩放
开发语言·前端·javascript
kong790692838 分钟前
环境搭建-运行前端工程
前端
CodeLinghu42 分钟前
提示词链模式:一种利用LLM大语言模型处理复杂任务的强大范式
前端·人工智能·语言模型
J2虾虾1 小时前
关于Ant Design Vue
前端·javascript·vue.js
程序员笨鸟1 小时前
[特殊字符] React 高频 useEffect 导致页面崩溃的真实案例:从根因排查到彻底优化
前端·javascript·学习·react.js·面试·前端框架
Highcharts.js1 小时前
从旧版到新版:Highcharts for React 迁移全攻略 + 开发者必知的 5 大坑
前端·react.js·前端框架·编辑器·highcharts