免费无码视频,五月婷婷丁香,亚洲日韩一区二区,亚洲精品黄色,久久日韩精品一区二区三区色欲,成人在线网站,无码国产精品一区二区高潮,亚洲精品一区

品優(yōu)網(wǎng)絡(luò) 十六年(2003-2018)專注
如何在網(wǎng)頁中制作移動的浮動層
日期:2014-12-18 作者:admin 來源: 瀏覽次數(shù):0 網(wǎng)友評論 0

企業(yè)網(wǎng)站推廣1

許多人也許會問,好多大型網(wǎng)站上的浮動圖標(biāo)是怎么實現(xiàn)的呢,在下面這篇文章里就和大家說說:

前幾步,請將下列原代碼加入html文件的<html>和</html>之間:

<style type="text/css" media="screen">
#floater {
position: absolute;
left: 500;
top: 146;
width: 125;
visibility: visible;
z-index: 10;
}
-->
</style>

**步,請將下列原代碼加入body的任何地方(建議更后):

<div ID="floater" style="left: 590px; top: 58px">

<p align="center"><img SRC="../pic/logo.gif" WIDTH="80" HEIGHT="30"><br></p>
</div><script LANGUAGE="JavaScript">
self.onError=null;
currentX = currentY = 0;
whichIt = null;
lastScrollX = 0; lastScrollY = 0;
NS = (document.layers) ? 1 : 0;
IE = (document.all) ? 1: 0;
<!-- STALKER CODE -->
function heartBeat() {
if(IE) { diffY = document.body.scrollTop; diffX = document.body.scrollLeft; }
if(NS) { diffY = self.pageYOffset; diffX = self.pageXOffset; }
if(diffY != lastScrollY) {
percent = .1 * (diffY - lastScrollY);
if(percent > 0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) document.all.floater.style.pixelTop += percent;
if(NS) document.floater.top += percent;
lastScrollY = lastScrollY + percent;
}
if(diffX != lastScrollX) {
percent = .1 * (diffX - lastScrollX);
if(percent > 0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) document.all.floater.style.pixelLeft += percent;
if(NS) document.floater.left += percent;
lastScrollX = lastScrollX + percent;
}
}
<!-- /STALKER CODE -->
<!-- DRAG DROP CODE -->
function checkFocus(x,y) {
stalkerx = document.floater.pageX;
stalkery = document.floater.pageY;
stalkerwidth = document.floater.clip.width;
stalkerheight = document.floater.clip.height;
if( (x > stalkerx && x < (stalkerx+stalkerwidth)) && (y > stalkery && y < (stalkery+stalkerheight))) return true;
else return false;
}
function grabIt(e) {
if(IE) {
whichIt = event.srcElement;
while (whichIt.id.indexOf("floater") == -1) {
whichIt = whichIt.parentElement;
if (whichIt == null) { return true; }
}
whichIt.style.pixelLeft = whichIt.offsetLeft;
whichIt.style.pixelTop = whichIt.offsetTop;
currentX = (event.clientX + document.body.scrollLeft);
currentY = (event.clientY + document.body.scrollTop);
} else {
window.captureEvents(Event.MOUSEMOVE);
if(checkFocus (e.pageX,e.pageY)) {
whichIt = document.floater;
StalkerTouchedX = e.pageX-document.floater.pageX;
StalkerTouchedY = e.pageY-document.floater.pageY;
}
}
return true;
}
function moveIt(e) {
if (whichIt == null) { return false; }
if(IE) {
newX = (event.clientX + document.body.scrollLeft);
newY = (event.clientY + document.body.scrollTop);
distanceX = (newX - currentX); distanceY = (newY - currentY);
currentX = newX; currentY = newY;
whichIt.style.pixelLeft += distanceX;
whichIt.style.pixelTop += distanceY;
if(whichIt.style.pixelTop < document.body.scrollTop) whichIt.style.pixelTop = document.body.scrollTop;
if(whichIt.style.pixelLeft < document.body.scrollLeft) whichIt.style.pixelLeft = document.body.scrollLeft;
if(whichIt.style.pixelLeft > document.body.offsetWidth - document.body.scrollLeft - whichIt.style.pixelWidth - 20) whichIt.style.pixelLeft = document.body.offsetWidth - whichIt.style.pixelWidth - 20;
if(whichIt.style.pixelTop > document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5) whichIt.style.pixelTop = document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5;
event.returnValue = false;
} else {
whichIt.moveTo(e.pageX-StalkerTouchedX,e.pageY-StalkerTouchedY);
if(whichIt.left < 0+self.pageXOffset) whichIt.left = 0+self.pageXOffset;
if(whichIt.top < 0+self.pageYOffset) whichIt.top = 0+self.pageYOffset;
if( (whichIt.left + whichIt.clip.width) >= (window.innerWidth+self.pageXOffset-17)) whichIt.left = ((window.innerWidth+self.pageXOffset)-whichIt.clip.width)-17;
if( (whichIt.top + whichIt.clip.height) >= (window.innerHeight+self.pageYOffset-17)) whichIt.top = ((window.innerHeight+self.pageYOffset)-whichIt.clip.height)-17;
return false;
}
return false;
}
function dropIt() {
whichIt = null;
if(NS) window.releaseEvents (Event.MOUSEMOVE);
return true;
}
<!-- DRAG DROP CODE -->
if(NS) {
window.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN);
window.onmousedown = grabIt;
window.onmousemove = moveIt;
window.onmouseup = dropIt;
}
if(IE) {
document.onmousedown = grabIt;
document.onmousemove = moveIt;
document.onmouseup = dropIt;
}
if(NS || IE) action = window.setInterval("heartBeat()",1);
</script>

  修改上面紅色顯示的語句,改為你自己的圖片路徑,并且修改圖片的大小,就完成了!

如何在網(wǎng)頁中制作移動的浮動層,與大家多多交流。

企業(yè)網(wǎng)站推廣2

查看更多寧波網(wǎng)站建設(shè)網(wǎng)頁如何在

寧波網(wǎng)站建設(shè) (http://m.liejin.net.cn/) 版權(quán)與免責(zé)聲明
    1、凡本網(wǎng)注明“來源:寧波品優(yōu)網(wǎng)絡(luò)”字樣的所有作品,版權(quán)均屬于浙江省寧波海曙品優(yōu)網(wǎng)絡(luò)技術(shù)有限公司,如需轉(zhuǎn)載、摘編或利用其它方式使用上述作品,請與本網(wǎng)聯(lián)系。
    2、凡本網(wǎng)注明“來源:XXX(非寧波品優(yōu)網(wǎng)絡(luò))”的作品,均轉(zhuǎn)載自其它媒體,轉(zhuǎn)載目的在于傳遞更多信息,并不代表本網(wǎng)贊同其觀點和對其真實性負(fù)責(zé)。寧波網(wǎng)站建設(shè)的轉(zhuǎn)載僅為信息的廣泛傳播,如有侵權(quán)請及時告之刪除。
返回:寧波網(wǎng)站建設(shè)
景宁| 东乌珠穆沁旗| 红安县| 来安县| 微博| 文登市| 大兴区| 云浮市| 尼勒克县| 隆回县| 嵩明县| 临猗县| 眉山市| 南乐县| 长乐市| 辽阳市| 伊金霍洛旗| 彭泽县| 双柏县| 基隆市| 平阴县| 夏津县| 沁水县| 河源市| 常熟市| 揭阳市| 石阡县| 抚州市| 新丰县| 金溪县| 汶川县| 韶关市| 三明市| 剑川县| 海林市| 马尔康县| 宁都县| 岳阳市| 吉水县| 胶南市| 甘南县|