求一个效果 就是吸附到网站底端的一个漂浮图片 无论网只能怎么上下拉滚动条这个 图片都紧紧的漂浮在网站最底下面这样的效果怎么做呢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!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> <style type="text/css" > /*Make position:fixed work in IE6!*/.fixed-bottom /* position fixed Bottom */{position:fixed;bottom:0;top:auto;}* html,* html body /* IE6 Fixed Position Jitter Fix */{background-image:url(about:blank);background-attachment:fixed;}* html .fixed-bottom /* IE6 position fixed Bottom */{position:absolute;bottom:auto;top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));} </style></head><body><div style="height:2000px;"></div><img src="images/test2.jpg" class="fixed-bottom" /></body></html> 楼主想吸附到哪儿就吸附到哪儿吧,jQuery对浏览器的兼容性比较好,expression只支持IE而已。//jQuery将div等固定在浏览器右上角的方法//$(window):浏览器对象//$(document.body):body对象//$(document):文档对象(function($){// 拓展自jQuery $.extend({// 静态方法写法(自定义一个叫osiris的类,避免与jQuery自身方法重名) osiris : { setTopRight : function($this){ $this.css({"display": "block", "position": "absolute", "text-align": "right"}) .animate( { left : $(window).width() - $this.width() }, 0) $(window).scroll(function(){ $this.animate( { top : $(document.body).scrollTop(), left : $(window).width() - $this.width() + $(document.body).scrollLeft() }, 0); }).resize(function(){ $this.animate( { left : $(window).width() - $this.width() }, 0); }); } } }); $.fn.extend({// 实例方法写法(这个我不会用自定义类的方法写成可以像“$(selector).osiris.setTopRight()”这样调用,会的同学欢迎提意见) setTopRight : function(){ var $this =$(this); $this.css({"display": "block", "position": "absolute", "text-align": "right"}) .animate( { left : $(window).width() - $this.width() }, 0) $(window).scroll(function(){ $this.animate( { top : $(document.body).scrollTop(), left : $(window).width() - $this.width() + $(document.body).scrollLeft() }, 0); }).resize(function(){ $this.animate( { left : $(window).width() - $this.width() }, 0); }); } });})(jQuery);// 调用方法$(document).ready(function(){ //$("#topRight").setTopRight(); //(1)实例方法,自身调用 $.osiris.setTopRight($("#topRight")); //(2)静态方法,调用jQuery的自定义类osiris里面的静态方法})// 用法:控件的直接parent标签必须是body,貌似是吧……<body><div id="topRight" style="width:100px; position: absolute;">topRight</></body>//用animate是因为我的浏览器ie8用offset()只能取值却改不了值,暂时不知道为啥…… 楼上的代码具体怎么使用?我的图片文件名在那里修改 放到index.htm主页里的代码是 最下面的那行吗? your key css codes is here:position:fixed;bottom:0; 童鞋们,我模拟了Google的电吉他 <script type="text/javascript">里如何post传递? 绝对高手入!!!有几行几列文本框,能不能用js将其实现成EXCEL样的操作呢? 如何获取iframe的宽度和高度? window.open参数的问题 怎样用javascript设置表的id 怎么返回N个月后的日期,需要考虑润年的情况 简单问题 快速送分 关于js遍历节点并赋值编号 如何制作一个javascript下拉导航菜单??? 怎样用JS在chrome浏览器上悬停取词,求大神帮帮忙 怎么在chrome浏览器下获得鼠标的坐标??急急急!
<!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>
<style type="text/css" >
/*Make position:fixed work in IE6!*/
.fixed-bottom /* position fixed Bottom */{position:fixed;bottom:0;top:auto;}
* html,* html body /* IE6 Fixed Position Jitter Fix */{background-image:url(about:blank);background-attachment:fixed;}
* html .fixed-bottom /* IE6 position fixed Bottom */{position:absolute;bottom:auto;top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));} </style>
</head>
<body><div style="height:2000px;"></div>
<img src="images/test2.jpg" class="fixed-bottom" />
</body>
</html>
//$(window):浏览器对象
//$(document.body):body对象
//$(document):文档对象
(function($){// 拓展自jQuery
$.extend({// 静态方法写法(自定义一个叫osiris的类,避免与jQuery自身方法重名)
osiris : {
setTopRight : function($this){
$this.css({"display": "block", "position": "absolute", "text-align": "right"})
.animate( {
left : $(window).width() - $this.width()
}, 0)
$(window).scroll(function(){
$this.animate( {
top : $(document.body).scrollTop(),
left : $(window).width() - $this.width() + $(document.body).scrollLeft()
}, 0);
}).resize(function(){
$this.animate( {
left : $(window).width() - $this.width()
}, 0);
});
}
}
});
$.fn.extend({// 实例方法写法(这个我不会用自定义类的方法写成可以像“$(selector).osiris.setTopRight()”这样调用,会的同学欢迎提意见)
setTopRight : function(){
var $this =$(this);
$this.css({"display": "block", "position": "absolute", "text-align": "right"})
.animate( {
left : $(window).width() - $this.width()
}, 0)
$(window).scroll(function(){
$this.animate( {
top : $(document.body).scrollTop(),
left : $(window).width() - $this.width() + $(document.body).scrollLeft()
}, 0);
}).resize(function(){
$this.animate( {
left : $(window).width() - $this.width()
}, 0);
});
}
});
})(jQuery);// 调用方法
$(document).ready(function(){
//$("#topRight").setTopRight(); //(1)实例方法,自身调用
$.osiris.setTopRight($("#topRight")); //(2)静态方法,调用jQuery的自定义类osiris里面的静态方法
})// 用法:控件的直接parent标签必须是body,貌似是吧……
<body>
<div id="topRight" style="width:100px; position: absolute;">topRight</>
</body>//用animate是因为我的浏览器ie8用offset()只能取值却改不了值,暂时不知道为啥……
我的图片文件名在那里修改 放到index.htm主页里的代码是 最下面的那行吗?
position:fixed;
bottom:0;