父元素使用css3的transform属性后,子元素也会跟着扭曲,如何让子元素不受影响? 先谢谢各位了! 比如父元素transform: translate3d(x, y, z) 后,子元素能不能也加上旋转的属性,把自己转回来?
ringa_lee
Set descendants:
.children1, .children2, .childrenN { -moz-transform: none; -webkit-transform: none; -o-transform: none; -ms-transform: none; transform: none; }
Or let the descendants do the reverse operation, such as reverse rotation:
.parent { position: relative; background-color: yellow; width: 200px; height: 150px; margin: 70px; -webkit-transform: rotate(30deg); -moz-transform: rotate(30deg); -o-transform: rotate(30deg); -ms-transform: rotate(30deg); transform: rotate(30deg); } .child { position: absolute; top: 30px; left: 50px; background-color: green; width: 70px; height: 50px; -webkit-transform: rotate(-30deg); -moz-transform: rotate(-30deg); -o-transform: rotate(-30deg); -ms-transform: rotate(-30deg); transform: rotate(-30deg); }
There are two connections here, you can refer to them below: - Click me - Click me again
Set descendants:
Or let the descendants do the reverse operation, such as reverse rotation:
There are two connections here, you can refer to them below:
- Click me
- Click me again