簡單的輪播圖

h5+css3實現簡單輪播圖
代碼如下:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>Document</title>
	<style>
    	body{
        	margin: 0;
        	background-color: antiquewhite;
    	}
    	ul{
        	margin: 0;
        	padding: 0;
        	list-style: none;
    	}

    	.banner{
      		position: relative;
      		width: 500px;
      		height: 300px;
      		background-color:brown;
     		margin: 200px auto 0;
      		overflow: hidden;
    	}
   		.banner ul{
       		position: absolute;
       		left: 0px;
       		display: flex;  /*子元素橫排顯示   開啓彈性*/
      		width: 2000px;
       		height: 300px;
       		background-color: aqua;
       		animation: run 9s infinite;
 	  	}
   		.banner ul li{
       		/*float: left;    子元素橫排顯示*/
       		width: 500px;
       		height: 300px;
       		background-size: 500px 300px;
      	 }
 	  .banner ul li:nth-child(1){
      		 background-image: url(QQ圖片20190722165502.jpg);
	   }
	   	.banner ul li:nth-child(2){
      			 background-image: url(QQ圖片20190722165312.jpg);
  		 }
	   .banner ul li:nth-child(3){
      		 background-image: url(QQ圖片20190722165335.jpg);
	   }
  	 .banner ul li:nth-child(4){
     		  background-image: url(QQ圖片20190722165502.jpg);
	   }
 	  @keyframes run{
      	 0%{
         		  left:0;
      	 }
      	 35%{
          		 left:-500px;
     	  }
    	   70%{
          		 left:-1000px;
      	 }
      	 100%{
          		 left:-1500px;
      	 }
 	  }
  </style>
</head>
<body>
<div class="banner">
    <ul>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>
</div>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章