编辑您的代码:提交代码
<html>
<head>
<style>
div
{
width:160px;
height:120px;
}
img
{
position:relative;
}
span
{
position:absolute;
left:0px;
top:0px;
}
</style>
<script type="text/javascript">
mouseover=true
function coordinates()
{
if (!moveMe)
{
return
}
if (event.srcElement.id=="moveMe")
{
mouseover=true
pleft=document.getElementById('moveMe').style.pixelLeft
ptop=document.getElementById('moveMe').style.pixelTop
xcoor=event.clientX
ycoor=event.clientY
document.onmousemove=moveImage
}
}
function moveImage()
{
if (mouseover&&event.button==1)
{
document.getElementById('moveMe').style.pixelLeft=pleft+event.clientX-xcoor
document.getElementById('moveMe').style.pixelTop=ptop+event.clientY-ycoor
return false
}
}
function mouseup()
{
mouseover=false
}
document.onmousedown=coordinates
document.onmouseup=mouseup
</script>
</head>
<body>
<span>请移动这个图形:</span>
<br />
<div style="position:absolute;left:0;top:20;">
<img src="/i/eg_landscape.jpg" width="160" height="120" /></div>
<div style="position:absolute;left:0;top:20;filter:mask(color=#ffffff);width:160;height:120">
<img id="moveMe" src="/i/eg_smile.gif" width="40" height="40"></div>
</body>
</html>
查看结果:
请在上面的文本框中编辑您的代码,然后单击提交按钮测试结果。w3c0.com
W3c0.com 提供的内容仅用于培训。我们不保证内容的正确性。通过使用本站内容随之而来的风险与本站无关。W3c0 简体中文版的所有内容仅供测试,对任何法律问题及风险不承担任何责任。 当使用本站时,代表您已接受了本站的使用条款和隐私条款。版权所有,保留一切权利。 鲁ICP备15022115号