I have a div which contains elements using the php include function, and below I have a footer. The footer is only visible if you scroll to the bottom of the page, to save space.
Problem is that if the content height is small(e.g 300px) then the footer is not placed on the bottom of the page which makes the layout look not as good.
So my question is, can I position the footer on the bottom when no scrollbar appears on the browser window(meaning the content div height is small) ?
This can only be done with JavaScript, as there is no way for your server (PHP) to know the height of the window. That being said, it certainly can be done: if the content is less than the height of the browser window, you can e.g. set
position:fixedandbottom: 0pxon the footer div to stick it to the bottom of the window; otherwise, just let it be on the bottom of the content.