CSS如何让页脚总在正文下面?我试过的CSS页脚容易与正文重叠。

html-css013

CSS如何让页脚总在正文下面?我试过的CSS页脚容易与正文重叠。,第1张

<div>正文</div>

<div>页脚</div>

html结构上页脚在正文下面,那么不用任何css它本身就是在下面的,你多半是企图用定位来布局整个页面,然后就重叠了。

比如css文件里设置了

.top{

    position:absolute

    top:0px

    width:940px

    height:40px

    background-color:#c0c0c0

}

.bottom{

    position:absolute

    bottom:0px

    width:940px

    height:40px

    background-color:#0c0c0c

}

呢么在页面代码中首先在head引用一下该css,比如名字为demo.css

<link href="demo.css" rel="stylesheet" type="text/css" /><!--假设页面和css文件在一个目录-->

然后在页面的top使用div

<div class="top">Something</div>

在页面的bottom使用div

<div class="bottom">Something</div>