html - 如何让有transform效果的父元素不影响其子元素
ringa_lee
ringa_lee 2017-04-17 11:11:10
0
1
815

父元素使用css3的transform属性后,子元素也会跟着扭曲,如何让子元素不受影响?
先谢谢各位了!
比如父元素transform: translate3d(x, y, z) 后,子元素能不能也加上旋转的属性,把自己转回来?

ringa_lee
ringa_lee

ringa_lee

reply all(1)
左手右手慢动作

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template