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

相关推荐
未来之窗软件服务19 小时前
幽冥大陆(九十九)文件大小换算+软考—东方仙盟练气期
css·html·css3·计算机软考·仙盟创梦ide·东方仙盟
5967851542 天前
css装饰
前端·css·css3
hey_ner2 天前
进度条图表简单化
前端·css·css3
程序员小李白2 天前
动画2详细解析
前端·css·css3
Pilot-HJQ6 天前
固定 Element UI 表格表头的方法(超简单)
vue.js·学习·css3·html5
kilito_017 天前
数字时钟翻页效果
javascript·css·css3
码客前端8 天前
理解 Flex 布局中的 flex:1 与 min-width: 0 问题
前端·css·css3
程序员小李白8 天前
弹性盒子详细解析
前端·css·css3
Komorebi゛8 天前
【CSS】线性流动边框样式
前端·css·css3
be or not to be8 天前
CSS 背景(background)系列属性
前端·css·css3