国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
頁(yè)面元素可拖拽放置的實(shí)現(xiàn)原理
分類:JavaScript
基本上msn、microsoft Live 和GOOGLE個(gè)性主頁(yè) 元素可拖動(dòng)并放置的的實(shí)現(xiàn)原理就是對(duì)DOM的操作再加上JAVASCRIPT拖動(dòng)元素。實(shí)現(xiàn)起來(lái)實(shí)際上并不難,但是要做到很美觀并符合用戶習(xí)慣就需要一些時(shí)間思考了。
以下代碼實(shí)現(xiàn)了上述功能,雖然很簡(jiǎn)單,但是基本上說(shuō)明了原理。實(shí)現(xiàn)更高級(jí)的功能當(dāng)然還需要改進(jìn)。
<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>DropLayer2</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<style type="text/css">
div
{
border-right: lightgrey thin solid;
border-top: lightgrey thin solid;
font-weight: bold;
z-index: 2;
text-transform: capitalize;
border-left: lightgrey thin solid;
color: white;
border-bottom: lightgrey thin solid;
background-color: dimgray;
}
</style>
</head>
<body>
<div id="parentDiv" class="parentCss" style="width:100">
<div class="itemCss" onmouseover="InsertDiv(this)">one 1</div>
<div class="itemCss" onmouseover="InsertDiv(this)">two 2</div>
<div class="itemCss" onmouseover="InsertDiv(this)">three 3</div>
<div class="itemCss" onmouseover="InsertDiv(this)">four 4</div>
<div class="itemCss" onmouseover="InsertDiv(this)">five 5</div>
<div class="itemCss" onmouseover="InsertDiv(this)">six 6</div>
<div class="itemCss" onmouseover="InsertDiv(this)">seven 7</div>
<div class="itemCss" onmouseover="InsertDiv(this)">eight 8</div>
<div class="itemCss" onmouseover="InsertDiv(this)">nine 9</div>
<div class="itemCss" onmouseover="InsertDiv(this)">ten 10</div>
</div>
<script language="javascript">
<!--
var obj,obj2;  //引發(fā)事件對(duì)象
var rootNode;     //控制對(duì)象根節(jié)點(diǎn)
var IsDrag=false;   //是否抓起
var NullDiv;  //空臨時(shí)層
var x,y;   //鼠標(biāo)與控件的相對(duì)坐標(biāo)
window.onload = Prepare; //窗體加載時(shí)委托到Prepare
function Prepare()
{
//生成臨時(shí)層,并設(shè)置其屬性
NullDiv = document.createElement("div");
//獲得控制對(duì)象的根節(jié)點(diǎn)元素
rootNode = document.getElementById("parentDiv");
document.onmousemove=MoveIt; //當(dāng)鼠標(biāo)在文檔上移動(dòng)時(shí)事件委托到MoveIt
document.onmousedown=Drag;   //當(dāng)鼠標(biāo)按下時(shí)事件委托到Drag
document.onmouseup=Release;  //當(dāng)鼠標(biāo)釋放臺(tái)起時(shí)事件委托到Release
}
function Drag()
{
obj = event.srcElement;
x=0;//event.offsetX;
y=0;//event.offsetY;
obj.style.position='absolute';
obj.style.posTop=event.y-y;
obj.style.posLeft=event.x-x;
IsDrag=true;
}
function MoveIt()
{
//window.status = event.x+"|"+event.y+"|"+IsDrag+"|"+x+"|"+y;
if(IsDrag)
{
obj.style.posTop=event.y-y;
obj.style.posLeft=event.x-x;
}
}
function Release()
{
IsDrag=false;
NullDiv.style.display='none';
obj.style.position='';
rootNode.insertBefore(obj,obj2);
}
function InsertDiv(o)
{
if(IsDrag)
{
obj2=o;
NullDiv.style.display='';
NullDiv.style.height='18';
NullDiv.style.width='100';
rootNode.insertBefore(NullDiv,obj2);
}
}
//-->
</script>
</body>
</html>
TAG:頁(yè)面效果
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
常用作帖、發(fā)帖代碼集萃
能移動(dòng)的超級(jí)連接特效【比較酷】——讓你的網(wǎng)頁(yè)靚起來(lái)!
兩級(jí)導(dǎo)航菜單特效
DIV+CSS導(dǎo)航菜單代碼,挺不錯(cuò)的。共享下 - 《八零年代》.NET之家 - 博客園
最少代碼的可拖動(dòng)DIV - 蝦米博客 - JavaEye技術(shù)網(wǎng)站
DIV下拉式菜單
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服