最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

css控制div固定在浏览器底部实例代码

来源:动视网 责编:小采 时间:2020-11-27 18:52:09
文档

css控制div固定在浏览器底部实例代码

css控制div固定在浏览器底部实例代码:css控制div固定在浏览器底部注意:此功能仅用于页面高度较小页面。代码如下:<html> <head> <style type="text/css"> body{ margin:0px; } #main{ width:100%; height:50px; positi
推荐度:
导读css控制div固定在浏览器底部实例代码:css控制div固定在浏览器底部注意:此功能仅用于页面高度较小页面。代码如下:<html> <head> <style type="text/css"> body{ margin:0px; } #main{ width:100%; height:50px; positi
 css控制div固定在浏览器底部

注意:此功能仅用于页面高度较小页面。

代码如下:

<html>
<head>
<style type="text/css">
body{
 margin:0px;
}
#main{
 width:100%;
 height:50px;
 position:absolute;
 top:100%;
 margin-top:-50px;
 background:#360;
 color:white;
}
</style>
</head>
<body>
<div style="border:1px solid #f00;width:500px;height:1800px"></div>
<div id="main">bottom</div>
</body>
</html>

网上找了个更好的:

当浏览器窗口无限缩小,向右拖动滚动条不会出现空白。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>ie6层固定</title>
<style type="text/css">
<!--
.bookbox {
background-color: #09C;
height: 30px;
width: 100%;
position: fixed;
bottom: 0px;
left: auto;
right: auto;
line-height: 30px;
text-align: center;
_POSITION: absolute;/*兼容IE6*/
_TOP: expression(offsetParent.scrollTop+document.documentElement.clientHeight-this.offsetHeight);/*兼容IE6*/
}
.bookbox a{color: #FFF;}
-->
</style>
</head>
<body>
<div style="border:1px solid #f00;width:500px;height:2000px;">这个例子是实现层固定在浏览器窗口的最下面,兼容IE6.<br />
<br />
往下看,看页面的最下面</div>
<div class="bookbox">测试测试测试测试测试测试测试测试测试测试测试测试测试测试</div>
</body>
</html>

恩,感觉上面的对不是很好,这里网上找了个,挺实用的:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
html, body {
 height: 100%;
 overflow-y: auto
}
body, div, p, ul, ol, li, form, input {
 padding: 0; margin: 0;
}
body{
 position:relative;
 background: #fff;
}
#wp {
 border:1px solid #00f;
 height: auto;
 min-height: 100%;
 _height: 100%;
}
#ft {
 border:1px solid #f00;
 margin-top: -157px;
 padding: 50px 0 0;
}
#sc {
 border:1px solid #f00;
 width: 580px;
 margin: 0 auto;
 padding-left: 20px;
 padding-bottom: 157px;
}
#s {
 border:1px solid #f00;
 position: relative;
 height: 33px;
 z-index:9
}
</style>
</head>
<body>
 <div id="wp">
 <div id="sc">
 <div id="s"></div>
 </div>
 </div>
 <div id="ft">
 
 </div>
</body>
</html>

文档

css控制div固定在浏览器底部实例代码

css控制div固定在浏览器底部实例代码:css控制div固定在浏览器底部注意:此功能仅用于页面高度较小页面。代码如下:<html> <head> <style type="text/css"> body{ margin:0px; } #main{ width:100%; height:50px; positi
推荐度:
标签: 浏览器 固定 底部
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top