css3实现3D盒子

博客围绕CSS3和3D盒子展开,虽无具体内容,但可知与利用CSS3技术创建3D盒子相关,CSS3在前端开发中可实现丰富视觉效果,3D盒子是其应用场景之一。
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
        *{padding: 0;margin:0;}
        html,body{height: 100%;}
        .center{position: absolute;left: 0;right: 0;top:0;bottom: 0;margin:auto auto;}
        .maxDiv{ perspective: 1200px;width: 500px;height: 500px;}
        .minDiv{width: 150px;height: 150px; transform-style: preserve-3d;animation: go 8s linear infinite;}
        .minDiv > div{background:rgba(118,2,253,0.5);width: 150px;height: 150px;box-shadow: 0 0 15px rgba(118,2,253,0.4); position: absolute;transition: 1s;animation-play-state:running;}
        .minDiv:hover{animation-play-state:paused;}
        .minDiv:hover > div{animation: goColor 1s linear infinite; }
        .minDiv > div:nth-child(1){transform: translateZ(-75px);}
        .minDiv > div:nth-child(2){transform:rotateY(90deg) translateZ(75px);}
        .minDiv > div:nth-child(3){transform:rotateY(90deg) translateZ(-75px);}
        .minDiv > div:nth-child(4){transform:rotateX(90deg) translateZ(-75px);}
        .minDiv > div:nth-child(5){transform:rotateX(90deg) translateZ(75px);}
        .minDiv > div:nth-child(6){transform: translateZ(75px);}

        .minDiv:hover > div:nth-child(1){ transform:translateZ(-150px);}
        .minDiv:hover > div:nth-child(3){ transform:rotateY(90deg) translateZ(-150px); }
        .minDiv:hover > div:nth-child(4){ transform:rotateX(90deg) translateZ(-150px);}
        .minDiv:hover > div:nth-child(2){transform:rotateY(90deg) translateZ(150px);}
        .minDiv:hover > div:nth-child(5){transform:rotateX(90deg) translateZ(150px);}
        .minDiv:hover > div:nth-child(6){ transform: translateZ(150px);}
        .minDiv>span{display: block;height: 50px;width: 50px; transform-style: preserve-3d;}
        .minDiv:hover >span{animation: go 4s linear infinite;}
        .minDiv>span>div{height: 50px;width: 50px;position:         absolute;background:rgba(156,225,27,0.6);box-shadow: 0 0 10px rgba(156,225,27,0.5);}
        .minDiv>span>div:nth-child(1){transform: translateZ(-25px);}
        .minDiv>span>div:nth-child(2){transform:rotateY(90deg) translateZ(25px);}
        .minDiv>span>div:nth-child(3){transform:rotateY(90deg) translateZ(-25px);}
        .minDiv>span>div:nth-child(4){transform:rotateX(90deg) translateZ(-25px);}
        .minDiv>span>div:nth-child(5){transform:rotateX(90deg) translateZ(25px);}
        .minDiv>span>div:nth-child(6){transform: translateZ(25px);}
        @keyframes goColor{
            0%{background:rgba(118,2,253,0.2);box-shadow: 0 0 15px rgba(118,2,253,0.2);}
            50%{background:rgba(118,2,253,0.3);box-shadow: 0 0 15px rgba(118,2,253,0.3);}
            100%{background:rgba(118,2,253,0.2);box-shadow: 0 0 15px rgba(118,2,253,0.2);}
        }
        @keyframes go{
            100%{transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg) ;}
        }
    </style>
</head>
<div class="maxDiv center">
	<div class="minDiv">
		<div></div>
		<div></div>
		<div></div>
		<div></div>
		<div></div>
		<div></div>
		<span class="center">
			 <div></div>
			 <div></div>
			 <div></div>
			 <div></div>
			 <div></div>
			 <div></div>
 		    </span>
        </div>
</div>
</html>

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值