css3轮播图案例

轮播图案例

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        li {
            list-style: none;
        }
        .banner {
            margin: 100px auto;
            width: 554px;
            height: 315px;
            /* background-color: pink; */
            overflow: hidden;
            position:relative;     
        }
        .banner img {
            width: 564px;
            height: 315px;
            border-radius: 5%;
            vertical-align: middle;
        }
        .banner ul {
            display: flex;
        }
        .banner .zuo,
        .banner .you {
            /* 因为我们想让两边的标签
            只有鼠标悬停的时候才出现
            所以这里我们先将两个标签的显示属性设置为none*/
            display: none;
            position: absolute;
            width: 20px;
            height: 30px;
            top: 50%;
            transform: translateY();
            background-color: rgba(0,0,0,0.3);
            text-decoration: none;
            color: white;
            line-height: 30px;
        }
        .banner .zuo{
            left: 0;
            border-radius: 0 15px 15px 0;
        }
        .banner .you{
            right: 0;
            border-radius:15px 0 0 15 px;
            text-align: center;
        }
        .banner:hover .zuo, .banner:hover .you {
            /* 这边设置的是鼠标悬停时标签才会出现 */
            display: block;
        }
        .banner ol {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            height: 13px;
            background-color: rgba(255,255,255,0);
            display: flex;
        }
        .banner ol li {
            
            margin: 3px;
            width: 8px;
            height: 8px;
            background-color: #fff;
            border-radius: 50%;
            cursor: pointer;
        }
        .banner ol .active{
            background-color: #ff5000;
        }
    </style>
</head>
<body>
    <div class="banner">
        <ul>
            <li><a href="#"><img src="./images/2.jpg" alt=""></a></li>
            <li><a href="#"><img src="./images/3.jpg" alt=""></a></li>
            <li><a href="#"><img src="./images/1.jpg" alt=""></a></li>
        </ul>
        <!-- 注意这边可以去阿里图标库中寻找图标,然后导入
        这边使用简易版本 -->
        <a href="#" class="zuo"><</a>
        <a href="#" class="you">></a>
        <ol>
            <li class="active"></li>
            <li></li>
            <li></li>
        </ol>
    </div>
</body>
</html>
相关推荐
鼓掌MVP1 分钟前
Rust Web实战:构建高性能并发工具的艺术
开发语言·前端·rust·异步编程·内存安全·actix-web·高性能web服务
Mintopia11 分钟前
🌌 元宇宙 Web 场景中,AIGC 驱动的虚拟内容生成技术
前端·javascript·aigc
excel20 分钟前
一文彻底搞懂 Vue3 中 ref 的源码实现(含详细注释)
前端
鹏多多22 分钟前
react-konva实战指南:Canvas高性能+易维护的组件化图形开发实现教程
前端·javascript·react.js
excel24 分钟前
一文彻底搞懂 Vue 中的 key(含 Vue2 / Vue3 对比)
前端
冰暮流星1 小时前
css新增盒子属性——尺寸调节
前端·css
程序员爱钓鱼1 小时前
Python编程实战 - 函数与模块化编程 - 函数的定义与调用
前端·后端·python
欧阳码农1 小时前
使用AI生成的页面总是被一眼认出来怎么办?1分钟给你解决
前端·后端
IT_陈寒1 小时前
7个鲜为人知的JavaScript性能优化技巧,让你的应用提速50%!
前端·人工智能·后端
艾小码1 小时前
前端别再乱存数据了!这3种存储方案让你的应用快如闪电
前端·javascript