About height in css
Hi everyone
Sometime when I post some codepen and when I wrote his
some people use to laugh and say is not usefull so now I have a question
look this codepen
https://codepen.io/alpha_66/pen/KKEVeQK?editors=1100
in the body I put my div is on the center on the page so now Try to comment in the body
height .
question why my blue div is not is the center on the page ????
Kevin Powell make a video about it he say is a mistakes some begenners use to make
thanks by advance
5 Replies
why it's not in the center if you comment out the height? Because the body height = height of the elements that are inside of it
If you want the body to be the whole height you want to use
min-height
instead so if content were to be bigger than the screen height it will na able to scrollmeans to put in the body is usefull !!!!
it all depends on your project sometimes you need it sometimes you don't and as @z- ::theProblemSolver:: said use min-height instead if you need to
it should be a
min-height
if you set anything, your content + padding should make up the size. putting heights creates problems, and fixed heights create migraines. were you to add more content to this page, enough that you had to scroll down to see the rest and had a fixed-height of 100vh on your body, all your content would overflow