使用css3写一个轮播图带小圆点(伪类)

代码展示

<!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>
    #frame {
            position: absolute; 
            left: 400px;
            top: 200px;
            width: 300px;
            height: 200px;
            overflow: hidden;
            border-radius:5px;
            }
            #dis {
            position: absolute;
            left: -50px;
            top: -10px;
            opacity: 0.5;
            }
            #dis li {
            display: inline-block;
            width: 200px;
            height: 20px;
            margin: 0 50px;
            text-align: center;
            color: #fff;
            border-radius: 10px;
            background: #000;
            }
            #photos img {
            float: left;
            width:300px;
            height:200px;
            }
            #photos {
            position: absolute;z-index:9px;
            width: calc(300px * 5);
            }
            .play{
            animation: ma 20s ease-out infinite alternate;/**/
            }
            @keyframes ma {
            0%,20% { margin-left: 0px; }
            25%,40% { margin-left: -300px; }
            45%,60% { margin-left: -600px; }
            65%,80% { margin-left: -900px; }
            85%,100% { margin-left: -1200px; }
            }
            .num{
            position:absolute;z-index:10;
            display:inline-block;
            right:10px;
            top:165px;
            border-radius:100%;
            background:#f00;
            width:25px;
            height:25px;
            line-height:25px;
            cursor:pointer;
            color:#fff;
            text-align:center;
            opacity:0.8;
            }
            .num:hover{background:#00f;}
            .num:hover,#photos:hover{animation-play-state:paused;}
            .num:nth-child(2){margin-right:30px}
            .num:nth-child(3){margin-right:60px}
            .num:nth-child(4){margin-right:90px}
            .num:nth-child(5){margin-right:120px}
            #a1:hover ~ #photos{animation: ma1 .5s ease-out forwards;}
            #a2:hover ~ #photos{animation: ma2 .5s ease-out forwards;}
            #a3:hover ~ #photos{animation: ma3 .5s ease-out forwards;}
            #a4:hover ~ #photos{animation: ma4 .5s ease-out forwards;}
            #a5:hover ~ #photos {animation: ma5 .5s ease-out forwards;}
            @keyframes ma1 {0%{margin-left:-1200px;}100%{margin-left:-0px;} }
            @keyframes ma2 {0%{margin-left:-1200px;}100%{margin-left:-300px;} }
            @keyframes ma3 {100%{margin-left:-600px;} }
            @keyframes ma4 {100%{margin-left:-900px;} }
            @keyframes ma5 {100%{margin-left:-1200px;} }
    </style>
</head>
<body>
    <div id="frame" >
        <a id="a1" class="num">1</a>
        <a id="a2" class="num">2</a>
        <a id="a3" class="num">3</a>
        <a id="a4" class="num">4</a>
        <a id="a5" class="num">5</a>
        <div id="photos" class="play">
          <img src="1.png" >
          <img src="2.png" >
          <img src="3.png">
          <img src="4.png" >
          <img src="5.png" >
          <ul id="dis">
          <li></li>
          <li></li>
          <li></li>
          <li></li>
          <li></li>
          </ul>
        </div>
        </div>
</body>
</html>
  • 23
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值