You've already solved your problem. Your code does exactly what you need it to do, it's just a CSS layout issue now.
https://codepen.io/anon/pen/xLWGzp?editors=0100
Because of the perspective changes, if you hang everything off the x-axis center everything will begin to line up properly:
(I'm just adding in the code changes here, I've left everything else the same)
#projection
perspective-origin: center top
.pro
transform-origin: center top
Now everything's lining up better, but it's still a bit off - you can change the $width
variable to anything other than 100%
to see the problem (60%
is a good one)
So the problem now is just due to the positioning of the elements, when you set position: absolute
they're default positioned to the left, change the width and add scale and transform and you get this equal-width/not-equal-position, so center them by adding:
#projection
position: relative
.pro
left: 50%
margin-left: $width * -.5
(info here as to why that works to center: https://css-tricks.com/quick-css-trick-how-to-center-an-object-exactly-in-the-center/)
So now jiggle $width
around to double-check, I tested it from 20%
up to 150%
and it works fine.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…