+ 1
How do I fix this đ
Pls am a beginner and I want to put an avatar div in the header div such day when I put a margin-top the header div would nt mov https://code.sololearn.com/W0y2kwAEbiJs/?ref=app
16 Answers
0
It works like this:
Header's height = 70px
If you do top:50% at .avatar, the top of it will be at 70px, but since .avatar's height = 50px, it'll look like this
_________________
| |
| |
| _____ |
| / \ |
| | | |
``````````````````````````
As you can see , the top is at 50% of the header, but since we need the center of .avatar, which is at 50% of .avatar, we move the .avatar up with 50% of it's own height, so the transform:translateY(-50%) moves the .avatar up with 50% of it's own height
+ 1
Check this one I think I did what you asked
https://code.sololearn.com/WnVP2vSpF110/?ref=app
+ 1
add padding : 10px; to #header
+ 1
Thank u all.... I appreciate this but can someone just please explain the position property and it's values
+ 1
Prof roel I love that explanation but the transform part I don't really understand
+ 1
Wow! Thanks
+ 1
Facebook id please prof roel đ©
+ 1
Thanks
0
Okay
0
lone beast gaming I don't have facebook, but you can message me through SoloLearn if you need help
0
Okay thanks
0
Prof roel can I please get an explanation on the css position property and it's values including the Css display property
0
lone beast gaming I think https://www.w3schools.com/ could help you better with that, since there are a fiew (static, initial, inherit, sticky) position values that I don't know and never use
0
For display:
- none: hides element
- block: shows element with like a <div>
- inline: shows element like a <span>
- inline-block: shows element like a <span> within a <div>
edit: Here is a code that might help you out
https://code.sololearn.com/W8WwssDhgVDp/?ref=app