ices_ 2017-04-08 06:38 采纳率: 0%
浏览 732

javascript代码,下面这段代码怎么实现,显示两张苹果的图片的

 <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>
  • 写回答

1条回答 默认 最新

  • zqbnqsdsmd 2017-04-08 15:34
    关注
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!