html5旋转立方体

演示:

代码:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			*{margin: 0;padding: 0;}
			body{
				background: black;
			}
			.box{width: 400px;height: 400px;margin: 150px auto;perspective: 1200px;}/*景深*/
			.box ul{width: 300px;height: 300px;margin: 50px auto;position: relative; animation: move 2s infinite linear; transform-origin: center center 150px;  transform-style: preserve-3d;}/*3d场景*/
			.box ul li{width: 300px;height: 300px;list-style: none;font-size: 100px; color: white;text-align: center;line-height: 300px;position: absolute;}
			.box ul li:nth-of-type(1){background: red;opacity: 0.4;}
			/* 向右平移300px,绕y轴旋转-90度*/
			.box ul li:nth-of-type(2){background: orange;opacity: 0.4;transform: translateX(300px) rotateY(-90deg);transform-origin: left;}
			/* 向左平移300px,绕y轴旋转90度*/
			.box ul li:nth-of-type(3){background: yellow;opacity: 0.4;transform: translateX(-300px) rotateY(90deg);transform-origin: right;}
			/* 向下平移300px,绕x轴旋转-90度*/
			.box ul li:nth-of-type(4){background: green;opacity: 0.4;transform: translateY(300px) rotateX(90deg);transform-origin: top;}
			/* 向上平移300px,绕x轴旋转90度*/
			.box ul li:nth-of-type(5){background: blue;opacity: 0.4;transform: translateY(-300px) rotateX(-90deg);transform-origin: bottom;}
			/* 向前平移300px */
			.box ul li:nth-of-type(6){background: purple;opacity: 0.4;transform: translateZ(300px);}
			
			/* 动画 */
			@keyframes move{
				from{transform: rotateY(0deg);}
				to{transform: rotateY(360deg);}
			}
		</style>
	</head>
	<body>
		<div class="box">
			<ul>
				<li>1</li>
				<li>2</li>
				<li>3</li>
				<li>4</li>
				<li>5</li>
				<li>6</li>
			</ul>
		</div>
	</body>
</html>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值