纯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>
相关推荐
深盾科技17 小时前
C++ 中 std::error_code 的应用与实践
java·前端·c++
Jagger_17 小时前
我的AI驯服记:从7640px大屏的惨败,到总结出一套高效协作SOP
前端
hy352817 小时前
VUE 踩坑合集
前端·javascript·vue.js
Franciz小测测18 小时前
Gemini 网页端自定义教程:利用 Stylus 强制开启宽屏显示
前端·css·stylus
彭不懂赶紧问18 小时前
鸿蒙NEXT开发浅进阶到精通15:从零搭建Navigation路由框架
前端·笔记·harmonyos·鸿蒙
xkxnq18 小时前
第一阶段:Vue 基础入门(第 2 天)
前端·javascript·vue.js
程序员刘禹锡18 小时前
定位与图标字体知识点全解析!!!(12.31)
前端·css·html·css3
wordbaby18 小时前
公私分明:为什么你不应该共用 SSH Key(附多账号最佳实践指南)
前端·git·ssh
多啦C梦a18 小时前
《双Token机制?》Next.js 双 Token 登录与无感刷新实战教程
前端·全栈·next.js
hxjhnct18 小时前
CSS中px,em,rem的区别
javascript·css·css3