简体   繁体   English

将页脚贴到身体div的底部

[英]Stick footer to bottom of body div

I'd like to know how I can stick my footer.php to the bottom of the body div. 我想知道如何将footer.php粘贴到body div的底部。

Here is what I'd like: http://prntscr.com/5ja375 这是我想要的: http : //prntscr.com/5ja375

Like I want it to be under the #base div any time. 就像我希望它随时都在#base div下。 That means if I type in a long paragraph, it's still gonna be under the base. 这意味着,如果我输入很长的一段,它仍然会处于基础之下。

Now here are the files: 现在是这些文件:

style.css style.css

/*Base Debut*/
#base {
    background-color:white;
    height:auto;
    width:1000px;
    position:absolute;
    top:0;
    left: 0;
    right: 0;
    margin: auto;
    margin-top: 80px;
}
/*Base Fin*/

/*Footer Debut*/
#foot {
    padding: 5px;
    margin: auto;
    background-color: #303030;
    width: 1000px;
    color: #7A7A7A;
    font-family: OswaldL;
    font-size: 14px;
    text-align: center;
}

#foot .under {
    background-color: #2B2B2B;
    width:1000px;
    height:10px;
}
/*Footer Fin*/

footer.php footer.php

<br /><br /><br /><br /><br />

            </div>
            </div>
            </div>

        <div id="foot">

            <?php echo'NOM_SITE;'?> © | Lorem ipsum <a href="#">dolor</a> et <a href="#">sit</a> | amet<br />
            <a target="_blank" href="/mobile">Lorem ipsum</a>


        <div class="under">
        </div>
        </div>
        <br />
    </body>
</html>

index.php index.php

<?php include 'head.php'; ?>
<div clas="wrap">
<div id="base">
Welcome to <?php echo NOM_SITE; ?> $date <?php echo date("d/m/Y") ?>
</div>
</div>
<?php include 'footer.php'; ?>

Thank you :) 谢谢 :)

If you want the footer sticks at bottom of your body, you need to set the body with position: relative; 如果您希望页脚位于身体底部,则需要将身体设置在以下位置:相对; and then footer with position: absolute; 然后页脚的位置:绝对; bottom: 0. 底部:0。

 #base { position: relative; z-index: 1; } footer { position: absolute; bottom: 0; z-index: 2; } 

And then, the HTML should be: 然后,HTML应该是:

 <div id="base"> your base content <footer> footer content </footer> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM