I am afraid that I do not know how to explain this at all, and I can show it. So I installed this script.
As you can see, the navigation menu is not where it should be. It should be installed exactly on the lower border of the head element and on the left border. That is, bottom: 0 and left: 0 . However, I set the rotation to -90degs, and it is obvious that absolute positioning in the nav element occurs before the rotation or, rather, from the original element, as if there was no rotation.
I tried using the :before and :after pseudo-elements to try to see if I could solve this problem. But I can not fully understand these pseudo-elements. In both cases, the rotation was bypassed. (Without rotation, the nav element obviously positions itself where it should be.)
This is basically the code:
<div id="head"> <div id="title">My Web</div> <nav> <ul> <li><a href="#">Home</a></li> <li><a href="#">About Me</a></li> <li><a href="#">Something Else</a></li> <li><a href="#">Blog</a></li> <li><a href="#">Contact</a></li> </ul> </nav> </div>
Nothing unusual.
And this is CSS (its parts that are relevant to this problem):
#head { position: relative; } nav { position: absolute; bottom: 0; left: 0; -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); -ms-transform: rotate(-90deg); -o-transform: rotate(-90deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); transform: rotate(-90deg); } nav a { display: inline-block; padding: 0 9px; }
How it works: you can see it in the Fiddle project.
Hope someone out there can give me a hand.
PS . In addition, sometimes, and depending on the size of the text inside the <a> tags, it seems that the distance between the vertical elements in nav slightly increases, as if it were half a pixel, which means that the borders become fuzzy. You can see this in this other version with only four characters and a space in one of the <a> elements. I canβt understand why this would make a difference. However, it makes the menu look pretty bad when this happens!
css rotation transform css-position rotatetransform
QuestionerNo27
source share