纯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>
相关推荐
超哥--6 小时前
B站视频内容智能分析系统(九):React 前端与管理面板
前端·react.js·前端框架
Cutecat_9 小时前
视频字幕处理工具横向:提取模式 vs 编辑模式,该如何选择
android·前端·ios·语音识别
qq_422152579 小时前
PDF 加水印工具怎么选?2026 年文档版权保护方案对比
前端·pdf·github
kyriewen10 小时前
手写 Promise.all、race、any:不到 30 行代码,解决并发异步的所有姿势
前端·javascript·面试
brucelee18610 小时前
OpenClaw 浏览器控制(Chrome MCP)完整教程
前端·chrome
ct97811 小时前
React 状态管理方案深度对比
开发语言·前端·react
胡志辉的博客11 小时前
深入浅出理解浏览器事件循环:从一道输出题讲到 Chrome 源码
前端·javascript·chrome·chromium·event loop
代码不加糖11 小时前
js中不会冒泡的事件有哪些?
前端·javascript·vue.js
懂懂tty11 小时前
Vue2与Vue3之间API差异
前端·javascript·vue.js
AI焦点12 小时前
跨越协议鸿沟:Tool Use状态机从Anthropic到OpenAI兼容体系的适配要点
前端·人工智能