preserve3d css3,CSS3 Flat和preserve-3d两种transform-style属性效果的演示

本文介绍了一种使用CSS实现的3D变换效果,通过设置不同的旋转角度和透视属性,可以使元素呈现出立体翻转的动画效果。具体包括了对元素应用rotateX变换,以及如何利用animation属性来定义动画循环播放。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

CSS

语言:

CSSSCSS

确定

body {

margin: 0;

}

div {

height: 130px;

width: 250px;

}

h3 {

margin: 0 0 30px;

}

.container {

height: 160px;

margin: 0 auto 1em;

-webkit-perspective: 500px;

perspective: 500px;

}

.top,

.bottom {

position: absolute;

bottom: 0;

-webkit-transform: rotateX(45deg);

transform: rotateX(45deg);

border-radius: 2px;

-webkit-animation: rotate 5s infinite;

animation: rotate 5s infinite;

}

.top {

background: rgba(255, 239, 0, .9);

}

.bottom {

-webkit-transform: rotateX(90deg);

transform: rotateX(90deg);

background: rgba(255, 37, 134, .9);

}

.style-flat .top,

.style-flat .bottom {

-webkit-transform-style: flat;

transform-style: flat;

}

.style-3d .top,

.style-3d .bottom {

-webkit-transform-style: preserve-3d;

transform-style: preserve-3d;

}

@-webkit-keyframes rotate {

50% {

transform: none;

}

}

@keyframes rotate {

50% {

transform: none;

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值