亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

css3繪制魔方

效果图1:嵌套            效果图2:不嵌套

https://img1.sycdn.imooc.com//5b7a7b7200011e7c03960355.jpg

https://img1.sycdn.imooc.com//5b7a7bc1000135f403480357.jpg

<!--去掉body中的small类标签,便是一个立方体-->
<!DOCTYPE html>
<html>
<head>
<title>3d魔方</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
.box {
display: block;
width: 200px;
height: 200px;
margin: 100px auto;
position: relative;
transform-style: preserve-3d;
}
.box:hover {
transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg);
transition: 10s;
}
li {
list-style: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: .3;
}
.small{
position: absolute;
width: 50%;
height: 50%;
top:25%;
left: 25%;
opacity: .6;
}
/*正*/
li:nth-child(1){
transform: translateZ(100px);
background: lightblue;
}
li:nth-child(7){
transform: translateZ(50px);
background: lightblue;
}
/*上*/
li:nth-child(2){
transform: rotateX(90deg) translateZ(100px);
background: lawngreen;
}
li:nth-child(8){
transform: rotateX(90deg) translateZ(50px);
background: lawngreen;
}
/*后*/
li:nth-child(3),li:nth-child(9){
transform: rotateX(180deg) translateZ(100px);
background: pink;
}
li:nth-child(9){
transform: rotateX(180deg) translateZ(50px);
background: pink;
}
/*底*/
li:nth-child(4){
transform: rotateX(270deg) translateZ(100px);
background: greenyellow;
}
li:nth-child(10){
transform: rotateX(270deg) translateZ(50px);
background: greenyellow;
}
/*左*/
li:nth-child(5){
transform: rotateY(90deg) translateZ(100px);
background: yellow;
}
li:nth-child(11){
transform: rotateY(90deg) translateZ(50px);
background: yellow;
}
/*右*/
li:nth-child(6){
transform: rotateY(270deg) translateZ(100px);
background: orange;
}
li:nth-child(12){
transform: rotateY(270deg) translateZ(50px);
background: orange;
}
</style>
</head>
<body>
<ui class="box">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li class="small"></li>
<li class="small"></li>
<li class="small"></li>
<li class="small"></li>
<li class="small"></li>
<li class="small"></li>
</ui>
</body>
</html>


點擊查看更多內容
2人點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
Web前端工程師
手記
粉絲
4
獲贊與收藏
25

關注作者,訂閱最新文章

閱讀免費教程

感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消