Margin align inside container | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Margin align inside container

Container and h1 both goes down when margin-top for h1 is set. Why don't a container just stay at top when margin-top for h1 is set. Container stay on it's position when margin-left for h1 is set, and h1 creating a space for left container. It's work fine When margin-right for h1 is set, nothing happens https://code.sololearn.com/Wa3NIvmD7Cqn/?ref=app why this happens.,

1st Jun 2020, 1:13 PM
Dec Fathani
Dec Fathani - avatar
2 Answers
+ 3
I don't actually know the explanation but if you look for a solution, here it is : https://code.sololearn.com/WgBp5NYacter/?ref=app
1st Jun 2020, 4:34 PM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
0
Arb Rahim Badsa I tried using margin-top to make space between h1 and top container without moving the container. i don't know why i can't use margin to make that happen, so, it can be done using a padding. thanks for a help., anyway, i've edited a question
1st Jun 2020, 6:25 PM
Dec Fathani
Dec Fathani - avatar