css how to position an element at the bottom of the html page

This question already has an answer here:

  • How to align content of a div to the bottom? 24 answers
  • How do you get the footer to stay at the bottom of a Web page? 21 answers

  • 你的第一个div是200px,h标签大约需要200px,但你的屏幕尺寸大于400px,所以有空白,将底部0px添加到蓝色div


    尝试一下

       <!doctype html>
        <html>
        <body>
        <div style="height:200px;background-color:red;">
        </div>
        <h1>Some other content</h1>
        <h1>Some other content</h1>
        <h1>Some other content</h1>
        <div style="position: fixed;left: 0px;bottom: 0px;width: 100%;background-color:blue;color:white">
            footer
        </div>
    
        </body>
        </html>
    

    尝试这个

    <!doctype html>
    <html>
    <body>
    <div style="height:200px;background-color:red;">
    </div>
    <h1>Some other content</h1>
    <h1>Some other content</h1>
    <h1>Some other content</h1>
    <div style="height:25px;bottom:0px;background-color:blue;color:white">
        footer
    </div>
    
    </body>
    </html>
    
    链接地址: http://www.djcxy.com/p/75784.html

    上一篇: 将div放在底部

    下一篇: css如何在HTML页面的底部放置一个元素