白学的小知识[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 小时前
a-table 冻结列导致边框
前端·css·css3
爱上好庆祝2 天前
学习js的第2天
前端·css·学习·html·css3
林恒smileZAZ2 天前
CSS终于支持渐变色的过渡了[特殊字符]
css·html·css3
~无忧花开~3 天前
CSS全攻略:从基础到实战技巧
开发语言·前端·css·学习·css3
神明不懂浪漫3 天前
【第一章】HTML(一)——HTML简述及常用标签
前端·javascript·css·html·css3
是上好佳佳佳呀4 天前
【前端(八)】CSS3 属性值笔记:渐变、自定义字体与字体图标
前端·笔记·css3
青花瓷5 天前
在PyCharm的Django工程中修改初始页
css·html·css3
CyrusCJA6 天前
毛玻璃效果
前端·css·css3
05Nuyoah7 天前
CSS文本和字体属性,列表属性
javascript·css·css3
Rabbit码工7 天前
HTML5 与 CSS3 新特性全解析:从结构优化到视觉升级
前端·css·css3·html5