CSS基础 - 3.14 定位练习-轮播图

轮播图效果图

将多张图片置于同一位置(下图其实有三张图片),点击轮播按钮进行轮播。本代码所实现的轮播图是个静态页面,还未实现跳转功能。

  • 轮播图按钮是内容为>,<的div元素组成,这里其实用背景图更好。或者直接用按钮元素。
  • 图片下方有蒙层,上面标明的图片的介绍信息等等。
    在这里插入图片描述

HTML代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/轮播图.css">
</head>
<body>
    <div class="banner">
        <div class="imgs">
            <a href=""><img src="./img/1.jpg" alt=""></a>
            <a href=""><img src="./img/2.jpg" alt=""></a>
            <a href=""><img src="./img/3.jpg" alt=""></a>
         </div>
        <div class="left">&lt;</div>
        <div class="right">&gt;</div>
        <div class="modal">
            <div class="title">
                电影不是爱情,你们才是
            </div>
            <div class="dots">
                <ul>
                    <li></li>
                    <li></li>
                    <li></li>
                </ul>
            </div>
        </div>
    </div>    
</body>
</html>

CSS代码

.banner{
    width:1000px;
    height:1400px;
    border: 2px solid #333;
    overflow: hidden;/* 溢出隐藏,将多余的图片隐藏起来 */
    position: relative;
    cursor: pointer;    /* 鼠标的指针样式,移动到该地方时,鼠标的箭头变成了小手*/
}
.banner .imgs{
    width: 3100px;
    height:1400px;
    float: left;
}
.banner .imgs img{
    width:1000px;
    height:1400px;   
}
.banner .imgs a{
    float: left;
}
/* .left和.right所具备的统一样式,可以像这样一起写 */
.banner .left,
.banner .right{
    position: absolute;
    width: 50px;
    height: 50px;
    background-color: #fff;
    color: red;
    font-size: 3em;
    text-align: center;
    line-height: 50px;
    border-radius: 50%;
}
.banner .left:hover,
.banner .right:hover{
    background-color: #e3e4e5;
}
.banner .left{
    left: 20px;
    top: 0;
    bottom: 0;
    margin: auto;
}
.banner .right{
    right: 20px;
    top: 0;
    bottom: 0;
    margin: auto;
}
.banner .modal{  
    width: 100%;
    height: 50px;
    position: absolute;
    bottom: 0px;
    left: 0px;
    background-color: rgba(0, 0, 0, .3);
    color: white;
}
.banner .modal .title{
    float: left;
    margin-left: 20px;
    height: 50px;
    line-height: 50px;
}
.banner .modal .dots{
    float: right;
}
.banner .modal .dots li{
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: white;
    display: inline-block;   /* 将圆点变成行块盒,因此不用float元素便可排成一排 */
    margin: 0 10px;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值