如何用CSS把层固定在整个网页的最底部?

html-css011

如何用CSS把层固定在整个网页的最底部?,第1张

html代码

<body>

<DIV id="container">

<DI id="content">

<h1>Content</h1>

<p>请改变浏览器窗口的高度,以观察footer效果。</p>

<p>这里是示例文字,DIV固定………,这里是示例文字。</p>

</DIV>

<DIV Vid="footer">

<h1>Footer</h1>

</DIV>

</DIV>

</body>

CSS代码:

程序代码

body,html{

margin:0

padding:0

font:12px/1.5arial

height:100%

}

#container{

min-height:100%

position:relative

}

#content{

padding:10px

padding-bottom:60px

/*20px(font-size)

x2(line-height)+10px(padding)x2=60px*/

}

#footer{

position:absolute

bottom:0

padding:10px0

background-color:#AAA

width:100%

}

#footerh1{

font:20px/2Arial

margin:0

padding:010px

}

你好!

给body加个父级属性,给bottom加个子级属性。然后设置bottom定位位置底部。

例如body{position:relative}

.bottom:{position:absolutebottom:0}

希望对你有所帮助,望采纳。

你说的是像百度知道下面的工具栏这样的层吧!简单

例子:

<div id="aa">始终在屏幕的最下方</div>

<style>

#aa{

width:800px//定义宽度

height:40px//定义高度

background-color:#DDD//定义背景色

left:50%

margin-left:-400px//这句和上面一句配合使用令层在水平中间

top:100%

margin-top:-40px//这一句和上面一句配合令层永远处在屏幕最下方

}

</style>

直接粘贴这些代码可见效果。希望加分!!!