Why do the X lines fix when I enable the 65th line in CSS?

Can someone explain it to me why are they getting centered when I apply for position absolute? https://codepen.io/harunjonuzi/pen/NWOzwvQ?editors=1100
8 Replies
Chris Bolson
Chris Bolson•17mo ago
On your pseudo class for the "x" you need to uncomment the absolute position and center the lines. This should work:
position: absolute;
display:grid;
place-items: center;
position: absolute;
display:grid;
place-items: center;
Harun
Harun•17mo ago
My question is why is this happening, I know that position absolute fixes it... I just want to understand why does that seems to work
Chris Bolson
Chris Bolson•17mo ago
opps, sorry
Harun
Harun•17mo ago
😄
Chris Bolson
Chris Bolson•17mo ago
if you don't use absolute position the 2 lines will be placed in their normal position, one next to the other. If you comment out your rotations you will see this and will notice that neither of them are centered. So, when you rotate them they are being rotated around their relative center point and not the center of the cell. To further demonstrate this, if you only had a single line it would be centered as you expect as there is no other element pushing it away from the center.
Harun
Harun•17mo ago
this is exactly the kind of explanation I was looking for, thank you very much
Chris Bolson
Chris Bolson•17mo ago
sorry I miss-understood your original question - your question is clear, I just skimmed it badly.
Harun
Harun•17mo ago
it's okay, have a wonderful day sir 😄
Want results from more Discord servers?
Add your server