浮动飘窗代码html,页⾯飘窗代码#float {
position:absolute;
left:0px;
top:0px;
z-index:501;
}
.pfClose {
position:relative;
width:14px;
padding:2px;
background:#fb5252;
left:2px;
top:20px;
text-align:center;
font-weight:bold;
font-size:12px;
cursor:pointer;
color:#fff;
border-radius:100%;
box-shadow:0px 0px 5px #8c0202;
}
.pfClose:hover {
background:#d70303;
}
document.write("
");
document.write("
X
");
document.write("");
document.write("");
document.write("");
document.write("
");
var x = 0,
y = 0;
var xin = true,
yin = true;
var step = 1;
var delay = 15;
var obj = ElementById("float");
function closediv() {
obj.style.visibility = "hidden";
}
function float() {
var L = T = 0;
var R = document.documentElement.clientWidth - obj.offsetWidth; var B = document.documentElement.clientHeight - obj.offsetHeight; obj.style.left = x + document.documentElement.scrollLeft + "px"; p = y + document.documentElement.scrollTop + "px";
x = x + step * (xin ? 1 : -1);
if (x
xin = true;
x = L;
}
if (x > R) {
xin = false;
x = R;
}
y = y + step * (yin ? 1 : -1);
if (y
yin = true;
y = T;
}
if (y > B) {
yin = false;
y = B;
}
var itl = setInterval("float()", delay); useover = function() { clearInterval(itl);
}
itl = setInterval("float()", delay);
}
再加⼀个飘窗如下:
#float1 {
position:absolute;
left:0;
top:0;
z-index:502;
}
.pfClose {
position:relative;
width:14px;
padding:2px;
background:#fb5252;
left:2px;
top:20px;
text-align:center;
font-weight:bold;
font-size:12px;
cursor:pointer;
color:#fff;
border-radius:100%;
box-shadow:0px 0px 5px #8c0202; }
.pfClose:hover {
background:#d70303;
}
document.write("
document.write("
X
");
document.write("");
document.write(""); document.write("");
document.write("
html里的float是什么意思");
var x1 = 400,
y1 = 400;
var xin1 = true,
yin1 = true;
var step1 = 1;
var delay1 = 18;
var obj1 = ElementById("float1");
function closediv1() {
obj1.style.visibility = "hidden";
}
function float1() {
var L = T = 0;
var R = document.documentElement.clientWidth - obj1.offsetWidth;
var B = document.documentElement.clientHeight - obj1.offsetHeight; obj1.style.left = x1 - document.documentElement.scrollLeft + "px";
p = y1 + document.documentElement.scrollTop + "px";
x1 = x1 + step1 * (xin1 ? 1 : -1);
if (x1
xin1 = true;
x1 = L;
}
if (x1 > R) {
xin1 = false;
x1 = R;
}
y1 = y1 + step1 * (yin1 ? 1 : -1);
if (y1
yin1 = true;
y1 = T;
}
if (y1 > B) {
yin1 = false;
y1 = B;
}
}
var it2 = setInterval("float1()", delay1);
clearInterval(it2);
}
it2 = setInterval("float1()", delay1);
}
升级版本插件形式
;(function($, window, document, undefined) { //插件的名称 floatEleStart
$.fn.floatEleStart = function(options) {
//浮动元素
var floatDiv = this;
//设置默认值
var left = 0; //左上⾓的x坐标
var top = 0; //左上⾓的y坐标
var zIndex = 500; //默认显⽰的层级
var step = 1; //每步跨越的⼤⼩
var delay = 16; //延迟速度
//设置实际值
if(options && options.left){ left = options.left; }
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论