一个在浏览器底部固定浮动的DIV如何实现(只用css)?_html/css_WEB-ITnose
就在已有的页面用js动态插入一段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> <title>testing</title><style type="text/css">.shape{width:200px; height: 140px; position:fixed!important; position:absolute; right:5px; bottom:5px!important; bottom:auto; top: expression(eval(document.compatMode && document.compatMode=='CSS1Compat') ? documentElement.scrollTop+(documentElement.clientHeight - this.clientHeight):document.body.scrollTop+(document.body.clientHeight - this.clientHeight));}.shape .con{width:200px; height:100px; background: url(http://static.l99.com/skin/default/images/versus/pk_vote_record.gif) no-repeat;}.shape .btn{width:200px; height:40px; background: url(http://static.l99.com/skin/default/images/versus/pk_vote_record.gif) no-repeat 0 -100px;}.height{height:1300px;}</style></head><body><div class="shape"><div class="con"></div><div class="btn"></div></div><div class="height"></div></body></html>
http://hi.baidu.com/iamzhangxinxu/blog/item/f4b1f550d65cdd10367abe9d.html
<div style="left:0; bottom:0; POSITION:absolute; width:100px; height:100px; z-index:100;">我要固定浮动在底部</div>
到底要底部哪个位置,自己改下left:***
#foot{position:fixed;_position:absolute;bottom:0px;_bottom:0px;_margin-top:expression(this.style.pixelHeight+document.documentElement.scrollTop)}
试下。
我的意思是随便找个页面,粘贴上这段代码,这个div就可以固定浮动在页面最低端,
拖动滚动条浏览始终在最低端
<!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> <title>testing</title><style type="text/css">#foot{position:fixed;_position:absolute;bottom:0px;_bottom:0px;_margin-top:expression(this.style.pixelHeight+document.documentElement.scrollTop)}</style></head><body style="height:5000px;"><div id="foot">我不在下面?</div></body></html>
document.getElementById("shows").style.top=(document.documentElement.scrollTop || document.body.scrollTop)+ieheight-5-showsHeight+"px";
居屏幕底部。
HTML code
这位大哥写的确实没错,
不过我的要求是就一个div标签,
比如新建一个html,内容就是
我不在下面?
保存,不能有body和html,head标签,style就不起作用?
我的意思是随便找个页面,粘贴上这段代码,这个div就可以固定浮动在页面最低端,
拖动滚动条浏览始终在最低端
这个不能用吗?
<div style="left:0; bottom:0; POSITION:absolute; width:100px; height:100px; z-index:100;">我要固定浮动在底部</div>
引用 4 楼 coolzdp 的回复:
我的意思是随便找个页面,粘贴上这段代码,这个div就可以固定浮动在页面最低端,
拖动滚动条浏览始终在最低端
这个不能用吗?
HTML code
不能啊,我的意思是只有div标签,没有body,style就不起作用了好像
html, body {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
_overflow: hidden;
}
#container {
_width: 100%;
_height: 100%;
_overflow-y: scroll;
}
#bottom {
background-color: #0ff;
height: 30px;
width: 100%;
position: fixed;
bottom: 0;
z-index: 999;
/* ie6 fixed */
_position: absolute;
_bottom:-1px;
_right: 17px;
}
核心样式就两句:一句是position:fixed,另一句是bottom:0。
zell419 代码很正确,火狐,IE都兼容!
不错,很好很强大
我想问下,就在此情况下,能否让其也同时水平居中呢???
能同时实现水平居中么?
[Quote=引用 6 楼 的回复:]
document.getElementById("shows").style.top=(document.documentElement.scrollTop || document.body.scrollTop)+ieheight-5-showsHeight+"px";
这个可以~~

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

本文讨论了HTML&lt; Progress&gt;元素,其目的,样式和与&lt; meter&gt;元素。主要重点是使用&lt; progress&gt;为了完成任务和LT;仪表&gt;对于stati

本文讨论了html&lt; datalist&gt;元素,通过提供自动完整建议,改善用户体验并减少错误来增强表格。Character计数:159

本文讨论了使用HTML5表单验证属性,例如必需的,图案,最小,最大和长度限制,以直接在浏览器中验证用户输入。

本文讨论了HTML&lt; meter&gt;元素,用于在一个范围内显示标量或分数值及其在Web开发中的常见应用。它区分了&lt; meter&gt;从&lt; progress&gt;和前

本文讨论了视口元标签,这对于移动设备上的响应式Web设计至关重要。它解释了如何正确使用确保最佳的内容缩放和用户交互,而滥用可能会导致设计和可访问性问题。

本文讨论了&lt; iframe&gt;将外部内容嵌入网页,其常见用途,安全风险以及诸如对象标签和API等替代方案的目的。

GiteePages静态网站部署失败:404错误排查与解决在使用Gitee...
