How to position div at the bottom of a page

前端 未结 6 1112
小蘑菇
小蘑菇 2020-12-19 00:00

How can I set position of a

to the bottom of page with either CSS or jQuery?

6条回答
  •  清酒与你
    2020-12-19 00:38

    This has been answered already, but to give a little bit more context for non CSS-experts:

    Given the HTML

    
      
        

    Some content

    then the following css

    div.footer {
      position: absolute;
      bottom: 0;
      right: 0;
    }
    

    will position the text at the lower right corner of your viewport (browser window). Scrolling will move the footer text.

    If you use

    div.footer {
      position: fixed;
      bottom: 0;
      right: 0;
    }
    

    on the other hand, the footer will stay at the bottom of your viewport, even if you scroll. The same technique can be used with top: 0 and left: 0 btw, to position an element at the top left corner.

提交回复
热议问题