纯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>
相关推荐
非凡ghost28 分钟前
AI修图不“造假“,摄影师的出片效率加速器
服务器·前端·人工智能·电脑
梦醒沉醉28 分钟前
4、CSS入门——属性选择器
css
2601_9516152029 分钟前
网页设计模板源码 web前端模板网页源码下载
前端
mmsx29 分钟前
osmdroid 地图实战 03|地图的"分层世界":离线方案、图层模型与 Overlay 体系
android·前端
郭邯1 小时前
从零到一:我用 AI 写了个复利计算器,顺便治好了我的"公式恐惧症"
前端
Pointer Pursuit1 小时前
C++11特性(二)
前端·c++·算法
天道kabuto1 小时前
Vue3 升级踩坑:子组件 click 事件为什么会触发两次?
前端
Nayana1 小时前
《Web 到 HarmonyOS》-- Ability、Stage、模块化与路由导航
前端
ShineWinsu2 小时前
对于 Vue 3:从为什么学 Vue,到声明式渲染与数据响应式的解析
前端·javascript·vue.js
粥里有勺糖2 小时前
视野修炼-技术周刊第132期 | 一些有趣的组件
前端·github·aigc