复制代码 代码如下:
<!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" />
<title></title>
<style type="text/css">
body
{
height:2000px;
}
.float_mx{
background:#CCC;
width:100px;
height:100px;
display:none;
}
</style>
</head>
<body>
<div class="float_mx">
在此添加内容
</div>
<script src="/UploadFiles/2021-04-02/jquery.min.js"><script type="text/javascript">
(function($) {
$.fn.scrollBox = function(options){
var defaultOptions = {
speed: 0.1, //加速
time: 16, //移动速度
top: 200, //默认顶部
align: 'right', //浮动位置,可选左、右
mix: 0 //边距
};
var options = $.extend(defaultOptions, options);
this.each(function(){
var obj = $(this);
init();
function init(){
obj.css('display', 'block');
obj.css('position', 'absolute');
obj.css(options.align, options.mix);
obj.css('top', options.top+'px');
obj.css('z-index', '99');
move();
}
function back() {
acceleration = options.speed;
time = options.time;
var x1 = 0;
var y1 = 0;
var x2 = 0;
var y2 = 0;
if (document.documentElement) {
x1 = document.documentElement.scrollLeft || 0;
y1 = document.documentElement.scrollTop || 0;
}
if (document.body) {
x2 = document.body.scrollLeft || 0;
y2 = document.body.scrollTop || 0;
}
var x = Math.max(x1, x2);
var y = Math.max(y1, y2);
var speed = acceleration;
return {
l: x,
t: y,
s: speed
};
};
function move(){
var tip = obj;
var old = options.top;
var pos = back().t;
pos = pos - $(tip).Coordinate().y + options.top;
pos = $(tip).Coordinate().y + pos / 10;
if (pos < options.top) {
pos = options.top;
}
if (pos != old) {
tip.css('top',pos + "px");
}
old = pos;
window.setTimeout(function(){move();}, options.time);
};
});
};
$.fn.Coordinate = function(){
var E = $(this)[0];
var C = E.offsetTop;
var B = E.offsetLeft;
var A = E.offsetWidth;
var D = E.offsetHeight;
while (E = E.offsetParent) {
C += E.offsetTop;
B += E.offsetLeft;
}
return {
x: B,
y: C,
w: A,
h: D
};
};
})(jQuery);
$('.float_mx').scrollBox();
</script>
</body>
</html>
把下面这段代理放到单独的js文件中,代码中的css代码可以删掉,display设为none,是为了避免在页面未加载完,显示不正确的问题。
复制代码 代码如下:
(function($) {
$.fn.scrollBox = function(options){
var defaultOptions = {
speed: 0.1, //加速
time: 16, //移动速度
top: 200, //默认顶部
align: 'right', //浮动位置,可选左、右
mix: 0 //边距
};
var options = $.extend(defaultOptions, options);
this.each(function(){
var obj = $(this);
init();
function init(){
obj.css('display', 'block');
obj.css('position', 'absolute');
obj.css(options.align, options.mix);
obj.css('top', options.top+'px');
obj.css('z-index', '99');
move();
}
function back() {
acceleration = options.speed;
time = options.time;
var x1 = 0;
var y1 = 0;
var x2 = 0;
var y2 = 0;
if (document.documentElement) {
x1 = document.documentElement.scrollLeft || 0;
y1 = document.documentElement.scrollTop || 0;
}
if (document.body) {
x2 = document.body.scrollLeft || 0;
y2 = document.body.scrollTop || 0;
}
var x = Math.max(x1, x2);
var y = Math.max(y1, y2);
var speed = acceleration;
return {
l: x,
t: y,
s: speed
};
};
function move(){
var tip = obj;
var old = options.top;
var pos = back().t;
pos = pos - $(tip).Coordinate().y + options.top;
pos = $(tip).Coordinate().y + pos / 10;
if (pos < options.top) {
pos = options.top;
}
if (pos != old) {
tip.css('top',pos + "px");
}
old = pos;
window.setTimeout(function(){move();}, options.time);
};
});
};
$.fn.Coordinate = function(){
var E = $(this)[0];
var C = E.offsetTop;
var B = E.offsetLeft;
var A = E.offsetWidth;
var D = E.offsetHeight;
while (E = E.offsetParent) {
C += E.offsetTop;
B += E.offsetLeft;
}
return {
x: B,
y: C,
w: A,
h: D
};
};
})(jQuery);
<!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" />
<title></title>
<style type="text/css">
body
{
height:2000px;
}
.float_mx{
background:#CCC;
width:100px;
height:100px;
display:none;
}
</style>
</head>
<body>
<div class="float_mx">
在此添加内容
</div>
<script src="/UploadFiles/2021-04-02/jquery.min.js"><script type="text/javascript">
(function($) {
$.fn.scrollBox = function(options){
var defaultOptions = {
speed: 0.1, //加速
time: 16, //移动速度
top: 200, //默认顶部
align: 'right', //浮动位置,可选左、右
mix: 0 //边距
};
var options = $.extend(defaultOptions, options);
this.each(function(){
var obj = $(this);
init();
function init(){
obj.css('display', 'block');
obj.css('position', 'absolute');
obj.css(options.align, options.mix);
obj.css('top', options.top+'px');
obj.css('z-index', '99');
move();
}
function back() {
acceleration = options.speed;
time = options.time;
var x1 = 0;
var y1 = 0;
var x2 = 0;
var y2 = 0;
if (document.documentElement) {
x1 = document.documentElement.scrollLeft || 0;
y1 = document.documentElement.scrollTop || 0;
}
if (document.body) {
x2 = document.body.scrollLeft || 0;
y2 = document.body.scrollTop || 0;
}
var x = Math.max(x1, x2);
var y = Math.max(y1, y2);
var speed = acceleration;
return {
l: x,
t: y,
s: speed
};
};
function move(){
var tip = obj;
var old = options.top;
var pos = back().t;
pos = pos - $(tip).Coordinate().y + options.top;
pos = $(tip).Coordinate().y + pos / 10;
if (pos < options.top) {
pos = options.top;
}
if (pos != old) {
tip.css('top',pos + "px");
}
old = pos;
window.setTimeout(function(){move();}, options.time);
};
});
};
$.fn.Coordinate = function(){
var E = $(this)[0];
var C = E.offsetTop;
var B = E.offsetLeft;
var A = E.offsetWidth;
var D = E.offsetHeight;
while (E = E.offsetParent) {
C += E.offsetTop;
B += E.offsetLeft;
}
return {
x: B,
y: C,
w: A,
h: D
};
};
})(jQuery);
$('.float_mx').scrollBox();
</script>
</body>
</html>
把下面这段代理放到单独的js文件中,代码中的css代码可以删掉,display设为none,是为了避免在页面未加载完,显示不正确的问题。
复制代码 代码如下:
(function($) {
$.fn.scrollBox = function(options){
var defaultOptions = {
speed: 0.1, //加速
time: 16, //移动速度
top: 200, //默认顶部
align: 'right', //浮动位置,可选左、右
mix: 0 //边距
};
var options = $.extend(defaultOptions, options);
this.each(function(){
var obj = $(this);
init();
function init(){
obj.css('display', 'block');
obj.css('position', 'absolute');
obj.css(options.align, options.mix);
obj.css('top', options.top+'px');
obj.css('z-index', '99');
move();
}
function back() {
acceleration = options.speed;
time = options.time;
var x1 = 0;
var y1 = 0;
var x2 = 0;
var y2 = 0;
if (document.documentElement) {
x1 = document.documentElement.scrollLeft || 0;
y1 = document.documentElement.scrollTop || 0;
}
if (document.body) {
x2 = document.body.scrollLeft || 0;
y2 = document.body.scrollTop || 0;
}
var x = Math.max(x1, x2);
var y = Math.max(y1, y2);
var speed = acceleration;
return {
l: x,
t: y,
s: speed
};
};
function move(){
var tip = obj;
var old = options.top;
var pos = back().t;
pos = pos - $(tip).Coordinate().y + options.top;
pos = $(tip).Coordinate().y + pos / 10;
if (pos < options.top) {
pos = options.top;
}
if (pos != old) {
tip.css('top',pos + "px");
}
old = pos;
window.setTimeout(function(){move();}, options.time);
};
});
};
$.fn.Coordinate = function(){
var E = $(this)[0];
var C = E.offsetTop;
var B = E.offsetLeft;
var A = E.offsetWidth;
var D = E.offsetHeight;
while (E = E.offsetParent) {
C += E.offsetTop;
B += E.offsetLeft;
}
return {
x: B,
y: C,
w: A,
h: D
};
};
})(jQuery);
标签:
jquery,浮动框
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“基于jquery的一个浮动框(扩展性比较好 )”评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。