css 旋转木马简单实现

在这里插入图片描述
在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>Title</title>
		<style>
			body {
     
     
				perspective: 800px;
				transform-style: preserve-3d;
				transform: rotateX(-20deg);
				background-color: black;
			}

			section {
     
     
				position: relative;
				width: 200px;
				height: 140px;
				/*transform: rotateY(60deg);*/
				margin: 100px auto;
				border-radius: 25px;
				transform-style: preserve-3d;
				animation: rotate 5s linear infinite;
				background: url("");
				background-size: 100% 100%;
			}

			section:hover {
     
     
				animation-play-state: paused;
			}

			section div {
     
     
				position: absolute;
				top: 0;
				left: 0;
				width: 100%;
				height: 100%;
				border-radius: 25px;
			}

			section div:nth-child(1) {
     
     
				transform: translateZ(300px);
				background: url("");
				background-size: 100% 100%;
			}

			section div:nth-child(2) {
     
     
				transform: rotateY(45deg) translateZ(300px);
				background: url("../壁纸");
				background-size: 100% 100%;
			}

			section div:nth-child(3) {
     
     
				transform: rotateY(90deg) translateZ(300px);
				background: url("../壁纸");
				background-size: 100% 100%;
			}

			section div:nth-child(4) {
     
     
				transform: rotateY(135deg) translateZ(300px);
				background: url("../壁纸");
				background-size: 100% 100%;
			}

			section div:nth-child(5) {
     
     
				transform: rotateY(180deg) translateZ(300px);
				background: url("../壁纸/");
				background-size: 100% 100%;
			}

			section div:nth-child(6) {
     
     
				transform: rotateY(225deg) translateZ(300px);
				background: url("../壁纸/");
				background-size: 100% 100%;
			}

			section div:nth-child(7) {
     
     
				transform: rotateY(270deg) translateZ(300px);
				background: url("../壁纸/");
				background-size: 100% 100%;
			}

			section div:nth-child(8) {
     
     
				transform: rotateY(315deg) translateZ(300px);
				background: url("../壁纸/");
				background-size: 100% 100%;
			}

			@keyframes rotate {
     
     
				from {
     
     
					transform: rotateY(0);
				}
				to {
     
     
					transform: rotateY(360deg);
				}
			}
		</style>
	</head>
	<body>
		<section>
			<div></div>
			<div></div>
			<div></div>
			<div></div>
			<div></div>
			<div></div>
			<div></div>
			<div></div>
		</section>
	</body>
</html>

猜你喜欢

转载自blog.csdn.net/qq_44378358/article/details/108061913
今日推荐