margin-bottom not working in html/css | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

margin-bottom not working in html/css

I have tried to make footer stick to bottom of the page but it is not working. If have tried many methods like display: block; I don't want to use position:fixed etc. because that will make the footer interfere with other contents as the page is long and scrolling is required.

24th Dec 2019, 4:54 AM
harshit
harshit - avatar
6 Answers
+ 1
You can use Position : absolute; Bottom:0;
24th Dec 2019, 5:16 AM
Shubham Sharma
Shubham Sharma - avatar
0
Shubham Sharma thanks. What is the difference between bottom and margin-bottom. Why margin-bottom doesn't work in this case.
25th Dec 2019, 7:40 AM
harshit
harshit - avatar
0
Margin-bottom takes space between self and its next element Where bottom is not , it is realtive to the viewport.
25th Dec 2019, 7:51 AM
Shubham Sharma
Shubham Sharma - avatar
0
Bottom property works if elements position is other than relative.
25th Dec 2019, 8:51 AM
Shubham Sharma
Shubham Sharma - avatar
0
Shubham Sharma the method works but as my page is large so while scrolling (in mobile view) the footer interfere with other contents.
25th Dec 2019, 2:02 PM
harshit
harshit - avatar
0
Please provide link of Document
25th Dec 2019, 2:10 PM
Shubham Sharma
Shubham Sharma - avatar