I want to make a website where the (dynamic in height) header and footer have a fixed position. The content should start directly beneath the header. I made a quick example. (Yellow and red top positions are the same, I want the yellow DIV to start beneath the red DIV.)
If you set the header position to fixed, the content DIV is placed at the same top position of the header.
For example, if you use float, you can use clear: both to reset the position, is there also a possibility for position: fixed?
CSS Only Solution
Use some way to pad the space the header takes up at the top of the screen:
padding-top:margin-top:position:relative + top:Then have a separate CSS style sheet to change
heightfor regularviewports versus mobileviewports.(Or see below for JavaScript solution to set the
heightattribute dynamically.)HTML:
CSS (regular version):
CSS (mobile version):
JavaScript Solution
HTML (copy-and-paste-able):