描述:通过CSS3的动画来制作轮播图,该图片占满整个屏幕,通过点击下方对应的按钮,就可以实现图片的更换。
实现代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>全屏切换练习</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            list-style: none;
        }
        html,body{
            height: 100%;
        }
        body{
            overflow: hidden;
        }
        .img-box{
            position: absolute;
            width: 100%;
            height: 100%;
            z-index: 0;
        }
        .img-box img{
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0;
            left: 0;
        }
        .img-box img:target{
            z-index: 5;
        }
        .img-box img:nth-child(1):target{
            animation: showLeft 2s;
        }

        .img-box img:nth-child(2):target{
            animation: showTop 2s;
        }

        .img-box img:nth-child(3):target{
            animation: rot 2s;
        }
        .img-box img:nth-child(1){
            z-index:1;
        }
        ul{
            position: absolute;
            z-index:1;
            width: 300px;
            height:80px;
            left:50%;
            bottom:20px;
            margin-left:-150px;
        }

        ul li{
            float: left;
        }
        ul li a{
            display: block;
            width: 80px;
            height: 80px;
            background-color: pink;
            border-radius: 50%;
            margin-left:20px;
            text-align: center;
            line-height: 80px;
            font-size:30px;
            color:red;
            text-decoration: none;
        }
        @keyframes showLeft {
            0%{
              transform: translateX(-2000px);
            }
            100%{
                transform: translateY(0px);
            }
        }
        @keyframes rot {
            0%{
                transform: scale(0.5) rotate(345deg);
            }
            100%{
                transform: scale(1)rotate(0deg);
            }
        }
    </style>
</head>
<body>
<div class="img-box">
    <img src="images/bg2.jpg"  id="img1" alt=""/>
    <img src="images/bg3.jpg"  id="img2" alt=""/>
    <img src="images/bg5.jpg"  id="img3" alt=""/>
</div>
<ul>
    <li><a href="#img1">1</a></li>
    <li><a href="#img2">2</a></li>
    <li><a href="#img3">3</a></li>
</ul>
</body>
</html>
Last modification:July 9, 2018
If you think my article is useful to you, please feel free to appreciate