Html及CSS实现相册效果

Html及CSS实现相册效果

创建一个html文件,在此目录下新建一个文件夹img,然后在里面存入照片(照片目录:img/1.jpg)实现相册效果

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>相册</title>
		<style type="text/css">
			body{
           
    
				perspective: 800px;
			}
			
			.box{
           
    
				/* 相对定位 */
				position: relative;
				width: 380px;
				height: 300px;
				/* 居中 */
				margin: 200px auto;
				/* 保留3d 效果 */
				transform-style: preserve-3d;
				
				transform: rotateX(-20deg);
				
				animation: rotatu 6s linear infinite;
			}
			
			.box:hover{
           
    
				/* 动画暂停 */
				animation-play-state: paused;
			}
			.box>div{
           
    
				/* 绝对定位 */
				position: absolute;
				top: 0;
				left: 0;
				width: 380px;
				height: 300px;
				background-image: url(img/1.jpg);
				background-size: cover;
			}
			
			.box>div:nth-child(1){
           
    
				transform: translateZ(450px);
			}
			
			.box>div:nth-child(2){
           
    
				transform: rotateY(60deg)  translateZ(450px) ;
			}
			.box>div:nth-child(3){
           
    
				transform: rotateY(120deg) translateZ(450px) ;
			}
			
			.box>div:nth-child(4){
           
    
				transform: rotateY(180deg) translateZ(450px) ;
			}
			.box>div:nth-child(5){
           
    
				transform: rotateY(240deg) translateZ(450px) ;
			}
			.box>div:nth-child(6){
           
    
				transform: rotateY(300deg) translateZ(450px) ;
			}
			
			@keyframes rotatu{
           
    
				from{
           
    
					transform: rotateX(-20deg) rotateY(0deg);
				}
				to{
           
    
					transform: rotateX(-20deg) rotateY(360deg);
				}
			}
			
		</style>
	</head>
	<body>
		<div class="box">
			
			<div></div>
			<div></div>
			<div></div>
			<div></div>
			<div></div>
			<div></div>
		</div>
	</body>
</html>
经验分享 程序员 微信小程序 职场和发展