白学的小知识[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是轮播所用时间。

相关推荐
橘子编程2 天前
CSS 全栈指南:从基础到 2025 新特性
前端·css·chrome·tensorflow·less·css3·html5
whuhewei2 天前
CSS文字渐变
前端·css·css3
Predestination王瀞潞3 天前
6.5.2 软件->W3C HTML5、CSS3标准(W3C Recommendation):HTML(HyperText Markup Language)
html·css3·html5
Predestination王瀞潞3 天前
6.5.3 软件->W3C HTML5、CSS3标准(W3C Recommendation):Selector网页选择器
前端·css3·html5
Predestination王瀞潞3 天前
6.5.1 软件->W3C HTML5、CSS3标准(W3C Recommendation):CSS(Cascading Style Sheet)
css·css3·html5
BugShare3 天前
有趣味的登录页它踏着七彩祥云来了
vue·css3
xiaotao1313 天前
什么是 Tailwind CSS
前端·css·css3
小J听不清5 天前
CSS 外边距(margin)全解析:取值规则 + 实战用法
前端·javascript·css·html·css3
小J听不清5 天前
CSS 边框(border)全解析:样式 / 宽度 / 颜色 / 方向取值
前端·javascript·css·html·css3
小J听不清6 天前
CSS 内边距(padding)全解析:取值规则 + 表格实战
前端·javascript·css·html·css3