【发布时间】:2020-12-04 06:41:01
【问题描述】:
html {
font-size: 0.7rem;
}
div div {
top: 5rem;
background-color: #444;
transform-origin: top center;
}
.rotate_x {
animation-name: rotate_x;
}
@keyframes rotate_x {
0% {
transform: rotateX( 0deg );
}
100% {
transform: rotateX( 360deg );
}
}
.rotate_y {
animation-name: rotate_y;
}
@keyframes rotate_y {
0% {
transform: rotateY( 0deg );
}
100% {
transform: rotateY( 180deg );
}
}
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
animation-duration: 5s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
html, body {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
width: 100%;
}
body {
perspective: 5rem;
}
div {
position: relative;
top: -1.5rem;
width: 5rem;
height: 5rem;
background-color: #222;
border-radius: 0.5rem;
}
</style>
<div class='rotate_y'>
<div class='rotate_x'>
</div>
</div>
灰色底部div 似乎没有像预期的那样垂直于黑色顶部div 旋转。相反,底部的灰色 div 似乎会缩小,直到它具有负值并被反转。想要的结果是底部灰色div 像铰链一样向上旋转;在 3D 空间中制作“L”形
在它一直向上并翻转以在另一侧做同样的事情之前。随着父 div 旋转 360 度。
如何使底部div 在与其父 div 连接时创建一个“L”形?
【问题讨论】:
标签: html css 3d css-animations css-transforms