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

相关推荐
feixing_fx5 天前
CSS 变量(Custom Properties):构建可扩展的主题切换系统
前端·css·前端框架·html·css3
东鹏特饮11 天前
经典打砖块(Breakout)游戏
前端·css·css3
java1234_小锋20 天前
【技术专题】CSS3 网页技术 - CSS3 布局进阶
前端·css·css3
java1234_小锋20 天前
【技术专题】CSS3 网页技术 - CSS3 视觉增强
前端·css·css3
东鹏特饮22 天前
本机状态监控页面html
运维·css·html·css3
java1234_小锋23 天前
【技术专题】CSS3 网页技术 - CSS3 基础样式
android·前端·css3
java1234_小锋24 天前
【技术专题】CSS3 网页技术 - CSS3 盒模型
前端·css·css3
java1234_小锋25 天前
【技术专题】CSS3 网页技术 - CSS3 单位、颜色、字体与文本
前端·css·css3
java1234_小锋1 个月前
【技术专题】CSS3 网页技术 - CSS3 优先级
前端·css·css3
java1234_小锋1 个月前
【技术专题】CSS3 网页技术 - CSS3 简介 & CSS 语法:选择器、属性、值、声明块
css3·1024程序员节