How do I fix this 👇 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

22nd May 2019, 9:41 PM
Lod
Lod - avatar
14 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
23rd May 2019, 9:00 AM
Roel
Roel - avatar
+ 1
Check this one I think I did what you asked https://code.sololearn.com/WnVP2vSpF110/?ref=app
22nd May 2019, 10:30 PM
Roel
Roel - avatar
+ 1
add padding : 10px; to #header
23rd May 2019, 12:17 AM
Gordon
Gordon - avatar
+ 1
Thank u all.... I appreciate this but can someone just please explain the position property and it's values
23rd May 2019, 8:47 AM
Lod
Lod - avatar
+ 1
Prof roel I love that explanation but the transform part I don't really understand
23rd May 2019, 8:53 AM
Lod
Lod - avatar
+ 1
Wow! Thanks
23rd May 2019, 9:14 AM
Lod
Lod - avatar
+ 1
Facebook id please prof roel 😩
23rd May 2019, 9:15 AM
Lod
Lod - avatar
+ 1
Thanks
23rd May 2019, 4:53 PM
Lod
Lod - avatar
0
Okay
23rd May 2019, 9:30 AM
Lod
Lod - avatar
0
lone beast gaming I don't have facebook, but you can message me through SoloLearn if you need help
23rd May 2019, 9:52 AM
Roel
Roel - avatar
0
Okay thanks
23rd May 2019, 2:06 PM
Lod
Lod - avatar
0
Prof roel can I please get an explanation on the css position property and it's values including the Css display property
23rd May 2019, 2:30 PM
Lod
Lod - avatar
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
23rd May 2019, 4:37 PM
Roel
Roel - avatar
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
23rd May 2019, 4:40 PM
Roel
Roel - avatar