0
点赞
收藏
分享

微信扫一扫

CSS实现轮播图效果以及遮罩效果

E_topia 2022-02-11 阅读 118
csscss3html

效果:

默认效果
静态
鼠标经过
鼠标经过

源码

<!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>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul {
            list-style: none;
        }

        a {
            color: black;
            text-decoration: none;
        }

        .tbprop {
            position: relative;
            margin: 100px auto;
            width: 520px;
            height: 280px;

        }

        .tbprop img {
            width: 520px;
            height: 280px;
            border-radius: 10px;
        }

        .tbprop .prev,
        .tbprop .next {
            position: absolute;
            top: 50%;
            margin-top: 12px;
            width: 15px;
            height: 25px;
            background-color: rgba(0, 0, 0, .3);
            border-radius: 0 15px 15px 0;
            color: #fff;
        }

        .tbprop .prev {

            left: 0;
            border-radius: 0 15px 15px 0;

        }

        .tbprop .next {

            right: 0;
            border-radius: 15px 0 0 15px;

        }

        .tbprop .spots {
            position: absolute;
            background-color: rgba(255, 255, 255, .5);
            width: 80px;
            height: 16px;
            bottom: 10px;
            left: 50%;
            margin-left: -40px;
            border-radius: 8px 8px 8px 8px;
        }

        .tbprop .spots li {
            float: left;
            background-color: #fff;
            width: 8px;
            height: 8px;
            border-radius: 4px;
            margin: 4px;
        }

        .tbprop .spots .selected {
            float: left;
            background-color: red;
            width: 8px;
            height: 8px;
            border-radius: 4px;
            margin: 4px;
        }

        .mask {
            display: none;
            position: absolute;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, .5) url(photos/arr.png) no-repeat center;
            border-radius: 8px 8px 8px 8px;
        }

        .tbprop:hover .mask {
            display: block;
        }
    </style>
</head>

<body>

    <div class="tbprop">
        <div class="mask"></div>
        <img src="photos/yupi1.jpg" alt="">
        <a href="#" class="prev">&lt;</a>
        <a href="#" class="next">&gt;</a>
        <div class="spots">
            <ul>
                <li></li>
                <li></li>
                <li class="selected"></li>
                <li></li>
                <li></li>
            </ul>
        </div>
    </div>
</body>

</html>
举报

相关推荐

0 条评论