白学的小知识[css3轮播]

代码如下:

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>轮播</title>
    <style>
        .boss {
            position: relative;
            width: 200px;
            height: 200px;
            overflow: hidden;
        }
        .boss>div {
            width: 10000px;
            height: 200px;
            border: 1px solid #000;
        }
        .box {
            display: flex;
            position: absolute;
            top: 0;
            left: 0;
        }
        .box>div {
            width: 200px;
            height: 200px;
            animation: move 10s infinite ease-out;
        }
        /* 关键帧 平移即可 */
        @keyframes move {
            0% {
                transform: translateX(0%);
            }
            25% {
                transform: translateX(-100%);
            }
            50% {
                transform: translateX(-200%);
            }
            75% {
                transform: translateX(-300%);
            }
            100% {
                transform: translateX(-400%);
            }
        }
    </style>
</head>
<body>
    <div class="boss">
        <div class="box">
            <!-- 第一个背景颜色是pink 最后一个也是pink色 -->
            <div style="background-color: red;"></div>
            <div style="background-color: yellow;"></div>
            <div style="background-color: blue;"></div>
            <div style="background-color: green;"></div>
            <div style="background-color: red;"></div>
        </div>
    </div>
</body>
</html>

样式:

css3轮播样式

上面代码中的:animation: move 10s infinite ease-out;

10s是轮播所用时间。

相关推荐
ヤ鬧鬧o.8 小时前
HTML安全密码备忘录
前端·javascript·css·html·css3
光影少年18 小时前
flex布局和grid布局区别,实现两边固定布局中间自适应
前端·css3·web·ai编程
Ulyanov1 天前
Impress.js深度解析
开发语言·前端·javascript·css3·impress.js
苯酸氨酰糖化物1 天前
HTML+CSS学信网学籍学历查询页面-支持任意修改内容信息
前端·css3·html5·娱乐
Southern Wind1 天前
从零开始封装一个优雅的图片上传组件 - 二次改装 Layui-Upload 的教程(附完整封装代码)
前端·javascript·html·layui·css3
米奇妙妙wuu3 天前
css实现文字和边框同样的渐变色效果
css·html·css3
我是伪码农5 天前
轮播图案例
css·html·css3
符文师5 天前
css3 新特性
前端·css3
n 55!w !1085 天前
静态网页作业
前端·css·css3
鸢尾掠地平6 天前
如何制作一个简单的学习教务系统?
css·学习·css3