2

3D

​ body {

​ margin: 0;

​ padding: 0;

​ height: 100vh;

​ width: 100vh;

​ background: url(images/0.jpg) no-repeat center/cover;

​ /*center/cover中cover是最优的解决方案,center 水平居中 */

​ }

​ .cube {

​ position: relative;

​ width: 300px;

​ height: 300px;

​ margin: 100px auto 0;

​ transform-style: preserve-3d;

​ animation: roll 4s linear infinite;

​ /* 开启父元素的3d模式 */

​ }

​ @keyframes roll {

​ 0% {

​ transform: rotateX(0deg) rotateY(0deg);

​ }

​ 100% {

​ transform: rotateX(360deg) rotateY(360deg);

​ }

​ }

​ /* @keyframes rotate是定义动画*/

​ .small {

​ /* float: left; 半脱离文档流 */

​ position: absolute;

​ top: 30px;

​ right: 100px;

​ /* 父亲相对定位position: relative;,子级给绝对定位position: absolute;,子级参照父级有一个偏移量,实现重叠 */

​ width: 300px;

​ height: 300px;

​ box-shadow: 0 0 50px 20px skyblue;

​ perspective: 1000px;

​ /* 最好加子元素上面,大小一致 */

​ transition:all 1s ease;

​ }

​ .small:nth-child(1) {

​ transform: rotateX(90deg) translateZ(150px) scale(1);

​ background: url(images/9.jpg) no-repeat center/cover;

​ border-radius: 20px;

​ }

​ .small:nth-child(2) {

​ transform: rotateX(-90deg) translateZ(150px) scale(1);

​ background: url(images/10.jpg) no-repeat center/cover;

​ border-radius: 20px;

​ }

​ .small:nth-child(3) {

​ transform: rotateY(90deg) translateZ(150px) scale(1);

​ background: url(images/11.jpg) no-repeat center/cover;

​ border-radius: 20px;

​ }

​ .small:nth-child(4) {

​ transform: rotateY(-90deg) translateZ(150px) scale(1);

​ background: url(images/12.jpg) no-repeat center/cover;

​ border-radius: 20px;

​ }

​ .small:nth-child(5) {

​ transform: translateZ(150px) scale(1);

​ background: url(images/15.jpg) no-repeat center/cover;

​ border-radius: 20px;

​ }

​ .small:nth-child(6) {

​ transform: translateZ(-150px) scale(1);

​ background: url(images/16.jpg) no-repeat center/cover;

​ border-radius: 20px;

​ }

.cube:hover .small:nth-child(1) {

​ transform: rotateX(90deg) translateZ(200px);

​ }

.cube:hover .small:nth-child(2) {

​ transform: rotateX(-90deg) translateZ(200px);

​ }

.cube:hover .small:nth-child(3) {

​ transform: rotateY(90deg) translateZ(200px);

​ }

.cube:hover .small:nth-child(4) {

​ transform: rotateY(-90deg) translateZ(200px);

​ }

.cube:hover .small:nth-child(5) {

​ transform: translateZ(200px);

​ }

.cube:hover .small:nth-child(6) {

​ transform: translateZ(-200px);

​ }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值