Why css rotate messes up child's skew

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 18:54:18

问题


take a look this is div without parent being rotated only skew and then child skewed back.

child(redbox): skewed:-40deg

parent: skewed: 40deg

how it looks...

No if i only just rotate parent why does the red box gets messed up...

child(redbox): skewed:-40deg

parent: skewed: 40deg rotated: 40deg.

so whyyyy does just rotating parent messes up the whole thing so confused.

http://codepen.io/anon/pen/IyBvt

i think skewed is getting applied after rotation or something


回答1:


The way you do it, the skew of the parent and the skew of the child are not aligned anymore.

If you set this style to the parent, they are:

.box {
  background: lightblue;
  width: 100px;
  height: 100px;
  margin: 20px auto;
  transition: transform 1s linear;
  transform: rotate(40deg) skewy(40deg);
  transform-origin: right bottom;
  transform-style: preserve-3D;
}

Notice that the only change that I have made is changing the order, from

  transform: skewy(40deg) rotate(40deg) ;

To

  transform: rotate(40deg) skewy(40deg);

Also notice that now, the skew of the child, even though it is specified as "Y", is happening at 40 deg (because it is inside the 40deg rotation)



来源:https://stackoverflow.com/questions/18676996/why-css-rotate-messes-up-childs-skew

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!