用css3制作魔方怎么制作,css3绘制魔方

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

b929a11c3a38664babcb8a0c3a0201d7.png

8f0ca6377724ef04a36308b876f6e908.png

html>

3d魔方

* {

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;

}

打开App,阅读手记

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值