검색창에 친숙한 프롬프트로 제품 분류를 구현하기 위해 권장되는 js(인간-컴퓨터 상호 작용) 페이지 1/3_javascript 기술

PHP中文网
풀어 주다: 2016-05-16 19:13:20
원래의
1044명이 탐색했습니다.

가운데 표는 검색 양식을 나타냅니다. 제품 카테고리를 클릭하면 상자가 검색창을 가리키며 사용자에게 제품 카테고리를 클릭한 후 변경된 사항을 명확하게 알려줍니다.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<HTML> 
<HEAD> 
<TITLE>方框移动</TITLE> 
<style language="javascript"> 
<!-- 
body, td{ 
    font-size: 9pt; 
} 
--> 
</style> 
</HEAD> 

<BODY> 
<SCRIPT LANGUAGE="JavaScript"> 
<!-- 
var speed=10;//速度 
var ci = 10;//运动次数 
var left=0;//方框左位置 
var top=0;//方框上位置 
var width=0;//方框宽 
var height=0;//方框高 
var aimleft=0;//目标左位置 
var aimtop=0;//目标上位置 
var aimwidth=0;//目标宽 
var aimheight=0;//目标高 
var lb=0;//左步长 
var tb=0;//上步长 
var wb=0;//宽步长 
var hb=0;//高步长 

/* 
* 取得对象位置、大小 
* 取得目标对象位置、大小 
*/ 
function setSource(obj){ 
    left      = getOffset(obj).Left; 
    top       = getOffset(obj).Top; 
    width     = obj.offsetWidth; 
    height    = obj.offsetHeight; 
    aimleft   = getOffset(aim).Left; 
    aimtop    = getOffset(aim).Top; 
    aimwidth  = aim.offsetWidth; 
    aimheight = aim.offsetHeight; 
    fk.style.display=&#39;&#39;; 
} 

/** 
* 设置方向步长、宽高步长 
*/ 
function setStep(){ 
    lb = (aimleft-left)/ci; 
    tb = (aimtop-top)/ci; 
    wb = (aimwidth-width)/ci; 
    hb = (aimheight-height)/ci; 
} 

/** 
* 移动 
*/ 
function move(){ 
    setStep(); 
    left+=lb; 
    top+=tb; 
    width+=wb; 
    height+=hb; 
    if(left<aimleft-2 || top<aimtop-2 || width<aimwidth-2 || height<aimheight-2){ 
        fk.style.posLeft = left; 
        fk.style.posTop = top; 
        fk.style.posWidth = width; 
        fk.style.posHeight = height; 
    }else{ 
        hiddenFK(); 
        function() {clearInterval(MyMar)} 
    } 
} 

function hiddenFK(){ 
    fk.style.display=&#39;none&#39;; 
} 

/** 
* 取得某元素在页面中相对页面左上顶点的位置 
*/ 
function getOffset(obj){ 
    var offsetleft = obj.offsetLeft; 
    var offsettop = obj.offsetTop; 
    while (obj.offsetParent != document.body) 
    { 
        obj = obj.offsetParent; 
        offsetleft += obj.offsetLeft; 
        offsettop += obj.offsetTop; 
    } 
    return {Left : offsetleft, Top : offsettop}; 
} 
var MyMar=setInterval(move,speed); 

//--> 
</SCRIPT> 

<div id="fk" style="position: absolute; width: 46px; height: 20px; border: 1px solid #000000 ; display: none"></div> 
<TABLE style="border: 1px solid #666666" cellspacing=1 bgcolor=#ff1111 cellpadding=4 border=0> 
<TR bgcolor=#ffffff> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">笔记本</TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">小家电</TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">电冰箱</TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">波比娃娃</TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">小家电</TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">小家电</TD> 
</TR> 
</TABLE> 


 


 


 
<TABLE id="aim" style="border: 1px solid #666666 ; width: 227px; height: 300px;"> 
<TR> 
    <TD></TD> 
</TR> 
</TABLE> 

 

 

 

 
<TABLE style="border: 1px solid #666666" cellspacing=1 bgcolor=#ff1111 cellpadding=4 border=0> 
<TR bgcolor=#ffffff> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">笔记本</TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">小家电</TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">电冰箱</TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">波比娃娃</TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">小家电</TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">小家电</TD> 
</TR> 
</TABLE> 
</BODY> 
</HTML>
로그인 후 복사

ㅎㅎ 효과는 좋은데 ff 밑에 자잘한 문제가 있어서 수정했습니다. 세분화 추가

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<HTML> 
<HEAD> 
<TITLE>方框移动</TITLE> 
<meta http-equiv="Content-Type" content="text/html; charset=GBK"> 
<style language="javascript"> 
<!-- 
body, td{ 
    font-size: 9pt; 
} 
--> 
</style> 
</HEAD> 

<BODY> 
<SCRIPT LANGUAGE="JavaScript"> 
<!-- 
var speed=10;//速度 
var ci = 10;//运动次数 
var left=0;//方框左位置 
var top=0;//方框上位置 
var width=0;//方框宽 
var height=0;//方框高 
var aimleft=0;//目标左位置 
var aimtop=0;//目标上位置 
var aimwidth=0;//目标宽 
var aimheight=0;//目标高 
var lb=0;//左步长 
var tb=0;//上步长 
var wb=0;//宽步长 
var hb=0;//高步长 
var fk = null; 
var aim = null; 
function initObj(){ 
    if (!fk){fk = document.getElementById(&#39;fk&#39;);} 
    if (!aim){aim = document.getElementById(&#39;aim&#39;);} 
} 
/* 
* 取得对象位置、大小 
* 取得目标对象位置、大小 
*/ 
function setSource(obj){ 
    initObj(); 
    left      = getOffset(obj).Left; 
    top       = getOffset(obj).Top; 
    width     = obj.offsetWidth; 
    height    = obj.offsetHeight; 
    aimleft   = getOffset(aim).Left; 
    aimtop    = getOffset(aim).Top; 
    aimwidth  = aim.offsetWidth; 
    aimheight = aim.offsetHeight; 
    fk.style.display=&#39;&#39;; 
    clearInterval(MyMar); 
} 

/** 
* 设置方向步长、宽高步长 
*/ 
function setStep(){ 
    lb = (aimleft-left)/ci; 
    tb = (aimtop-top)/ci; 
    wb = (aimwidth-width)/ci; 
    hb = (aimheight-height)/ci; 
} 

/** 
* 移动 
*/ 
function move(){ 
    setStep(); 
    left+=lb; 
    top+=tb; 
    width+=wb; 
    height+=hb; 
    if(left<aimleft-2 || top<aimtop-2 || width<aimwidth-2 || height<aimheight-2){ 
        fk.style.left = left+"px"; 
        fk.style.top = top+"px"; 
        fk.style.width = width+"px"; 
        fk.style.height = height+"px"; 
    }else{ 
        hiddenFK(); 
        clearInterval(MyMar) 
    } 
} 

function hiddenFK(){ 
    initObj(); 
    fk.style.display=&#39;none&#39;; 
} 

/** 
* 取得某元素在页面中相对页面左上顶点的位置 
*/ 
function getOffset(obj){ 
    var offsetleft = obj.offsetLeft; 
    var offsettop = obj.offsetTop; 
    while (obj.offsetParent != document.body) 
    { 
        obj = obj.offsetParent; 
        offsetleft += obj.offsetLeft; 
        offsettop += obj.offsetTop; 
    } 
    return {Left : offsetleft, Top : offsettop}; 
} 
var MyMar=setInterval(move,speed); 

//--> 
</SCRIPT> 

<div id="fk" style="position: absolute; width: 46px; height: 20px; border: 1px solid #000000 ; display: none"></div> 
<TABLE style="border: 1px solid #666666" cellspacing=1 bgcolor=#ff1111 cellpadding=4 border=0> 
<TR bgcolor=#ffffff> 
    <TD onClick="setSource(this);MyMar=setInterval(move,speed)">笔记本</TD> 
    <TD onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</TD> 
    <TD onClick="setSource(this);{MyMar=setInterval(move,speed)}">电冰箱</TD> 
    <TD onClick="setSource(this);{MyMar=setInterval(move,speed)}">波比娃娃</TD> 
    <TD onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</TD> 
    <TD onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</TD> 
</TR> 
</TABLE> 


 


 


 
<TABLE id="aim" style="border: 1px solid #666666 ; width: 227px; height: 300px;"> 
<TR> 
    <TD></TD> 
</TR> 
</TABLE> 

 

 

 

 
<TABLE style="border: 1px solid #666666" cellspacing=1 bgcolor=#ff1111 cellpadding=4 border=0> 
<TR bgcolor=#ffffff> 
    <TD onClick="setSource(this);{MyMar=setInterval(move,speed)}">笔记本</TD> 
    <TD onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</TD> 
    <TD onClick="setSource(this);{MyMar=setInterval(move,speed)}">电冰箱</TD> 
    <TD onClick="setSource(this);{MyMar=setInterval(move,speed)}">波比娃娃</TD> 
    <TD onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</TD> 
    <TD onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</TD> 
</TR> 
</TABLE> 
</BODY> 
</HTML>
로그인 후 복사

마우스 프롬프트 추가
div로 변경 후

<html> 
<HEAD> 
<TITLE>方框移动</TITLE> 
<meta http-equiv="Content-Type" content="text/html; charset=GBK"> 
<style language="javascript"> 
<!-- 
body, div{ 
    font-size: 9pt; 
} 
ul { margin:0; padding:0} 
li { width:50px; background:#fff; float:left; cursor:pointer; border:1px solid #f11; text-align:center ; margin:3px; display:block} 
--> 
</style> 
</HEAD> 

<BODY> 
<SCRIPT LANGUAGE="JavaScript"> 
<!-- 
var speed=10;//速度 
var ci = 10;//运动次数 
var left=10;//方框左位置 
var top=20;//方框上位置 
var width=0;//方框宽 
var height=0;//方框高 
var aimleft=0;//目标左位置 
var aimtop=0;//目标上位置 
var aimwidth=0;//目标宽 
var aimheight=0;//目标高 
var lb=0;//左步长 
var tb=0;//上步长 
var wb=0;//宽步长 
var hb=0;//高步长 
var fk = null; 
var aim = null; 
function initObj(){ 
    if (!fk){fk = document.getElementById(&#39;fk&#39;);} 
    if (!aim){aim = document.getElementById(&#39;aim&#39;);} 
} 
/* 
* 取得对象位置、大小 
* 取得目标对象位置、大小 
*/ 
function setSource(obj){ 
    initObj(); 
    left      = getOffset(obj).Left; 
    top       = getOffset(obj).Top; 
    width     = obj.offsetWidth; 
    height    = obj.offsetHeight; 
    aimleft   = getOffset(aim).Left; 
    aimtop    = getOffset(aim).Top; 
    aimwidth  = aim.offsetWidth; 
    aimheight = aim.offsetHeight; 
    fk.style.display=&#39;&#39;; 
    clearInterval(MyMar); 
} 

/** 
* 设置方向步长、宽高步长 
*/ 
function setStep(){ 
    lb = (aimleft-left)/ci; 
    tb = (aimtop-top)/ci; 
    wb = (aimwidth-width)/ci; 
    hb = (aimheight-height)/ci; 
} 

/** 
* 移动 
*/ 
function move(){ 
    setStep(); 
    left+=lb; 
    top+=tb; 
    width+=wb; 
    height+=hb; 
    if(left<aimleft-2 || top<aimtop-2 || width<aimwidth-2 || height<aimheight-2){ 
        fk.style.left = left+"px"; 
        fk.style.top = top+"px"; 
        fk.style.width = width+"px"; 
        fk.style.height = height+"px"; 
    }else{ 
        hiddenFK(); 
        clearInterval(MyMar) 
    } 
} 

function hiddenFK(){ 
    initObj(); 
    fk.style.display=&#39;none&#39;; 
} 

/** 
* 取得某元素在页面中相对页面左上顶点的位置 
*/ 
function getOffset(obj){ 
    var offsetleft = obj.offsetLeft; 
    var offsettop = obj.offsetTop; 
    while (obj.offsetParent != document.body) 
    { 
        obj = obj.offsetParent; 
        offsetleft += obj.offsetLeft; 
        offsettop += obj.offsetTop; 
    } 
    return {Left : offsetleft, Top : offsettop}; 
} 
var MyMar=setInterval(move,speed); 

//--> 
</SCRIPT> 
<div id="fk" style="position: absolute; width: 46px; height: 20px; border: 1px solid #000000 ; display: none"></div> 
<ul> 
    <li onClick="setSource(this);MyMar=setInterval(move,speed)">笔记本</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">电冰箱</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">波比娃娃</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</li> 
</ul> 

<div id="aim" style=" clear:left;border: 1px solid #666666 ; width: 227px; height: 300px; margin:20px 10px"> 
</div> 
<ul> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">笔记本</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">电冰箱</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">波比娃娃</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</li> 
</ul> 
</BODY> 
</HTML>
로그인 후 복사

var left=10;//상자 왼쪽 위치
var top = 20;//상자에 위치

이 두 정의의 구체적인 용도가 무엇인지 모르겠습니다.
엄격한 인증 하에서는 어떻게 조정해도 10PX 정도의 차이가 나는데 왜 그럴까요?
크기를 변경해도 효과에는 영향이 없는 것 같습니다.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<HEAD> 
<TITLE>方框移动</TITLE> 
<meta http-equiv="Content-Type" content="text/html; charset=GBK"> 
<style language="javascript"> 
<!-- 
body, div{ 
    font-size: 9pt; 
} 
ul { margin:0; padding:0} 
li { width:50px; background:#fff; float:left; cursor:pointer; border:1px solid #f11; text-align:center ; margin:3px; display:block} 
--> 
</style> 
</HEAD> 

<BODY> 
<SCRIPT LANGUAGE="JavaScript"> 
<!-- 
var speed=10;//速度 
var ci = 10;//运动次数 
var left=0;//方框左位置 
var top=0;//方框上位置 
var width=0;//方框宽 
var height=0;//方框高 
var aimleft=0;//目标左位置 
var aimtop=0;//目标上位置 
var aimwidth=0;//目标宽 
var aimheight=0;//目标高 
var lb=0;//左步长 
var tb=0;//上步长 
var wb=0;//宽步长 
var hb=0;//高步长 
var fk = null; 
var aim = null; 
function initObj(){ 
    if (!fk){fk = document.getElementById(&#39;fk&#39;);} 
    if (!aim){aim = document.getElementById(&#39;aim&#39;);} 
} 
/* 
* 取得对象位置、大小 
* 取得目标对象位置、大小 
*/ 
function setSource(obj){ 
    initObj(); 
    left      = getOffset(obj).Left; 
    top       = getOffset(obj).Top; 
    width     = obj.offsetWidth; 
    height    = obj.offsetHeight; 
    aimleft   = getOffset(aim).Left; 
    aimtop    = getOffset(aim).Top; 
    aimwidth  = aim.offsetWidth; 
    aimheight = aim.offsetHeight; 
    fk.style.display=&#39;&#39;; 
    clearInterval(MyMar); 
} 

/** 
* 设置方向步长、宽高步长 
*/ 
function setStep(){ 
    lb = (aimleft-left)/ci; 
    tb = (aimtop-top)/ci; 
    wb = (aimwidth-width)/ci; 
    hb = (aimheight-height)/ci; 
} 

/** 
* 移动 
*/ 
function move(){ 
    setStep(); 
    left+=lb; 
    top+=tb; 
    width+=wb; 
    height+=hb; 
    if(left<aimleft-2 || top<aimtop-2 || width<aimwidth-2 || height<aimheight-2){ 
        fk.style.left = left+"px"; 
        fk.style.top = top+"px"; 
        fk.style.width = width+"px"; 
        fk.style.height = height+"px"; 
    }else{ 
        hiddenFK(); 
        clearInterval(MyMar) 
    } 
} 

function hiddenFK(){ 
    initObj(); 
    fk.style.display=&#39;none&#39;; 
} 

/** 
* 取得某元素在页面中相对页面左上顶点的位置 
*/ 
function getOffset(obj){ 
    var offsetleft = obj.offsetLeft; 
    var offsettop = obj.offsetTop; 
    while (obj.offsetParent != document.body) 
    { 
        obj = obj.offsetParent; 
        offsetleft += obj.offsetLeft; 
        offsettop += obj.offsetTop; 
    } 
    return {Left : offsetleft, Top : offsettop}; 
} 
var MyMar=setInterval(move,speed); 

//--> 
</SCRIPT> 
<div id="fk" style="position: absolute; width: 46px; height: 20px; border: 1px solid #000000 ; display: none"></div> 
<ul> 
    <li onClick="setSource(this);MyMar=setInterval(move,speed)">笔记本</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">电冰箱</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">波比娃娃</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</li> 
</ul> 

<div id="aim" style=" clear:left;border: 1px solid #666666 ; width: 227px; height: 300px; margin:20px 10px"> 
</div> 
<ul> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">笔记本</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">电冰箱</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">波比娃娃</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</li> 
    <li onClick="setSource(this);{MyMar=setInterval(move,speed)}">小家电</li> 
</ul> 
</BODY> 
</HTML>
로그인 후 복사

그라데이션 배경색을 추가한 후 속도가 느려집니다.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<HTML> 
<HEAD> 
<TITLE>方框移动</TITLE> 
<style language="javascript"> 
<!-- 
body, td{ 
    font-size: 9pt;FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=1,startColorStr=#ffffff,endColorStr=#999999); 
} 
--> 
</style> 
</HEAD> 

<BODY> 
<SCRIPT LANGUAGE="JavaScript"> 
<!-- 
var speed=10;//速度 
var ci = 10;//运动次数 
var left=0;//方框左位置 
var top=0;//方框上位置 
var width=0;//方框宽 
var height=0;//方框高 
var aimleft=0;//目标左位置 
var aimtop=0;//目标上位置 
var aimwidth=0;//目标宽 
var aimheight=0;//目标高 
var lb=0;//左步长 
var tb=0;//上步长 
var wb=0;//宽步长 
var hb=0;//高步长 

/* 
* 取得对象位置、大小 
* 取得目标对象位置、大小 
*/ 
function setSource(obj){ 
    left      = getOffset(obj).Left; 
    top       = getOffset(obj).Top; 
    width     = obj.offsetWidth; 
    height    = obj.offsetHeight; 
    aimleft   = getOffset(aim).Left; 
    aimtop    = getOffset(aim).Top; 
    aimwidth  = aim.offsetWidth; 
    aimheight = aim.offsetHeight; 
    fk.style.display=&#39;&#39;; 
} 

/** 
* 设置方向步长、宽高步长 
*/ 
function setStep(){ 
    lb = (aimleft-left)/ci; 
    tb = (aimtop-top)/ci; 
    wb = (aimwidth-width)/ci; 
    hb = (aimheight-height)/ci; 
} 

/** 
* 移动 
*/ 
function move(){ 
    setStep(); 
    left+=lb; 
    top+=tb; 
    width+=wb; 
    height+=hb; 
    if(left<aimleft-2 || top<aimtop-2 || width<aimwidth-2 || height<aimheight-2){ 
        fk.style.posLeft = left; 
        fk.style.posTop = top; 
        fk.style.posWidth = width; 
        fk.style.posHeight = height; 
    }else{ 
        hiddenFK(); 
        function() {clearInterval(MyMar)} 
    } 
} 

function hiddenFK(){ 
    fk.style.display=&#39;none&#39;; 
} 

/** 
* 取得某元素在页面中相对页面左上顶点的位置 
*/ 
function getOffset(obj){ 
    var offsetleft = obj.offsetLeft; 
    var offsettop = obj.offsetTop; 
    while (obj.offsetParent != document.body) 
    { 
        obj = obj.offsetParent; 
        offsetleft += obj.offsetLeft; 
        offsettop += obj.offsetTop; 
    } 
    return {Left : offsetleft, Top : offsettop}; 
} 
var MyMar=setInterval(move,speed); 

//--> 
</SCRIPT> 
<center> 
<div id="fk" style="position: absolute; width: 46px; height: 20px; border: 1px solid #000000 ; display: none">rerererer</div> 
<TABLE style="border: 1px solid #666666" cellspacing=1 bgcolor=#ff1111 cellpadding=4 border=0> 
<TR bgcolor=#ffffff> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">爱老虎油</TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">野火寒烟 </TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">剑气凌人</TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">火焰楼兰</TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">萧萧小雨</TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">筷子一根</TD> 
</TR> 
</TABLE> 


 


 


 
<TABLE id="aim" style="border: 1px solid #666666 ; width: 227px; height: 300px;"> 
<TR> 
    <TD></TD> 
</TR> 
</TABLE> 

 

 

 

 
<TABLE style="border: 1px solid #666666" cellspacing=1 bgcolor=#ff1111 cellpadding=4 border=0> 
<TR bgcolor=#ffffff> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">心灵鼓手</TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">心开风神 </TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">中国丫头 </TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">波比娃娃</TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">乱世狂闪</TD> 
    <TD onClick="setSource(this);function(){MyMar=setInterval(move,speed)}">红心男孩</TD> 
</TR> 
</TABLE> 
</BODY> 
</HTML>
로그인 후 복사

원리:
pixelTop과 offsetTop은 다르며, pixelTop은 실제로 숫자입니다. 상의 형태. 그리고 offsetTop은 객체의 실제 오프셋입니다.
처음에는 이 fk 객체의 상단이 정의되지 않아 pixelTop이 0이고, 실제 margin 값인 body의 margin이 존재하기 때문에 offsetTop은 0이 아닙니다.

원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿