开发者

CSS footer positioning question

Is it good practise to set absolute positioning of a开发者_运维问答 footer, if we know its height?

For example, if its height is 100px:

footer {  
  position:absolute;  
  bottom: 100px;  
  background: red;  
}  

And if its not, could you please help me to position a footer without divs, only with HTML5 tags, because i found some solutions, but they are with extra divs.


footer {
  position: absolute;
  bottom: 0;
  height: 100px;
  background: red;
}

When you specify the bottom position property you're positioning the bottom edge, so you don't need to account for the height like that. You'd only set it to 100px if you want the bottom edge to be 100px from the bottom of the page.

Usually the only time I find myself positioning the footer manually is if it's position: fixed though. Assuming your page flow isn't wacked it's usually easy enough to have it be the bottom element on the page naturally, which is what you're trying to achieve with position: absolute;.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜