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

相关推荐
荆州克莱1 天前
springcloud整合nacos、sentinal、springcloud-gateway,springboot security、oauth2总结
spring boot·spring·spring cloud·css3·技术
天高任鸟飞dyz1 天前
html加载页面
css·html·css3
好多吃的啊1 天前
文字阴影特效
css3
荆州克莱2 天前
杨敏博士:基于法律大模型的智能法律系统
spring boot·spring·spring cloud·css3·技术
Passion不晚3 天前
制作炫酷个人网页:用 HTML 和 CSS3 展现你的风格
前端·html·css3
安冬的码畜日常3 天前
【CSS in Depth 2 精译_029】5.2 Grid 网格布局中的网格结构剖析(上)
前端·css·css3·html5·grid·css布局·grid布局
安冬的码畜日常3 天前
【CSS in Depth 2 精译_030】5.2 Grid 网格布局中的网格结构剖析(下)
前端·css·css3·html5·flexbox·网格布局·css布局
荆州克莱4 天前
书生大模型全链路开源体系
spring boot·spring·spring cloud·css3·技术
安冬的码畜日常5 天前
【CSS in Depth 2 精译_031】5.3 Grid 网格布局的两种替代语法
前端·css·css3·html5·网格布局·网格·css布局
荆州克莱5 天前
React源码学习(一):如何学习React源码
spring boot·spring·spring cloud·css3·技术