gpt4 book ai didi

css - 在 div 的 A、B、C、D 等内部时,如何使 div X 始终保持相同的方向,其中每个都有不同的变换 :rotate()?

转载 作者:行者123 更新时间:2023-11-28 02:06:26 25 4
gpt4 key购买 nike

Please see this image to better understand:

请注意圆圈内的兔子。在示例 A 中,兔子与其父 div 一起旋转。在示例 B 中,它们始终遵循页面方向。

如果可能的话,我想只使用 CSS 实现 B。

PS:请记住,父 div 的旋转是随机的,因为它们可能以任何旋转出现。

最佳答案

您需要对兔子应用一个相等且相反的变换。

.holder {
width: 200px;
height: 50px;
background-color: red;
transform: rotate(30deg);
}

.holder > div {
position: absolute;
top: 50%;
left: 50%;
margin: -15px 0 0 -15px;
width: 30px;
height: 30px;
background-color: white;
transform: rotate(-30deg);
}
<div class="holder">
<div></div>
</div>

关于css - 在 div 的 A、B、C、D 等内部时,如何使 div X 始终保持相同的方向,其中每个都有不同的变换 :rotate()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48991896/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com