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

相关推荐
AI视觉网奇11 天前
three教学 3d资产拼接源代码
前端·css·css3
神明不懂浪漫12 天前
【第三章】CSS(一)——基础选择器、CSS的属性
前端·css·html·css3
智码看视界12 天前
老梁聊全栈:CSS3 高级特性—Flex/Grid 布局体系深度解析
前端·css3·布局·flexbox·grid·工程实践·全栈工程师
gz-郭小敏13 天前
优化横向滚动展示大量数据的时候数据晃动问题
前端·javascript·html·css3
贩卖黄昏的熊13 天前
flex 布局快速梳理
开发语言·javascript·css3·html5
川冰ICE15 天前
JavaScript实战④|天气查询应用,调用API与异步处理
javascript·css·css3
2501_9181269115 天前
一个上帝类程序作画
前端·css·css3
#麻辣小龙虾#15 天前
小学三年级语文小游戏
css·html·css3
Agatha方艺璇15 天前
前端开发技术复习笔记
vue·bootstrap·css3·html5·web
2501_9181269117 天前
小圆点踢足球
css·html·css3