CSS “transform: rotate()” affecting overall design with “position: absolute” (not aligning properly)

后端 未结 1 642
南笙
南笙 2021-02-15 03:34

I fear I quite don\'t know how to explain it as well as I can show it. So I\'ve set up this Fiddle.

As you can see, the nav menu is not where it should

相关标签:
1条回答
  • 2021-02-15 04:24

    This happens because the nav element has different width and height. By default an element is rotated by its centre, so in case of your nav the corners of this block after rotation don't match. The solution to this problem is to set the transform-orgin property that will move the rotation point so that the bottom left corners before and after transformation are in the same place. In your case it's transform-origin: 75px 75px; (works independently of the <a> length).

    Here's the fiddle

    Unfortunately it won't solve the problem for IE8- as those browsers doesn't support transformation and use their own way of rotating things.

    0 讨论(0)
提交回复
热议问题