在Widget代码中使用javascript从左向右滑动光标图像
Moving with cursor image left slide to right with javascript in Widget code
我想要这个小部件代码。我检查了所有的帖子,但它们对没有帮助
此代码在没有HTML&小工具中的CSS。但我想用下面的代码做一个类似鼠标悬停的演示。我糟糕的英语
<script type="text/javascript">
<!--
var imgObj = null;
var animate ;
function init(){
imgObj = document.getElementById('myImage');
imgObj.style.position= 'absolute';
imgObj.style.top = '240px';
imgObj.style.left = '-300px';
imgObj.style.visibility='hidden';
moveRight();
}
function moveRight(){
if (parseInt(imgObj.style.left)<=10)
{
imgObj.style.left = parseInt(imgObj.style.left) + 5 + 'px';
imgObj.style.visibility='visible';
animate = setTimeout(moveRight,20); // call moveRight in 20msec
//stopanimate = setTimeout(moveRight,20);
}
else
stop();
f();
}
function stop(){
clearTimeout(animate);
}
window.onload =init;
//-->
</script>
<img id="myImage" src="https://lh4.googleusercontent.com/proxy/LxuD_Ceq6NrRGBW2mF_6Cy9zeO_vqkV8ZTRMdzjc_LxE0InnXBLp1_BkWuyhlg0EMJPt-Njzzp5_4cuR562m6dh8QNTW_1kzsf9pXcXiKI2ZK6wEMJH2TAAiQqpQUewNMKI=s0-d" style="margin-left:170px;" />
您只需使用CSS3 transition
就可以做到这一点。检查以下更新。
* {
margin: 0px;
padding: 0px;
}
img {
cursor: pointer;
position: relative;
margin: -65px; /* Adjust this value to expose the image */
left: 0;
transition: left .5s;
}
img:hover {
left: 65px; /* Use same value as used as negative margin */
}
<img id="myImage" src="https://lh4.googleusercontent.com/proxy/LxuD_Ceq6NrRGBW2mF_6Cy9zeO_vqkV8ZTRMdzjc_LxE0InnXBLp1_BkWuyhlg0EMJPt-Njzzp5_4cuR562m6dh8QNTW_1kzsf9pXcXiKI2ZK6wEMJH2TAAiQqpQUewNMKI=s0-d" />
相关文章:
- 在Widget代码中使用javascript从左向右滑动光标图像
- 在Widget代码中没有jQuery的情况下,用光标图像从左滑动到右
- 图像阵列预加载时显示沙漏光标
- 使用JavaScript的带有背景图像的径向光标
- 如何使用JS捕捉带有垂直线的自定义图像光标
- Javascript用光标擦除图像
- 可以用我自己的自定义图像替换光标
- 使用Opera自定义base64图像光标-可能
- 如果光标在图像上在某种意义上不停止.它正在运行
- 使用Javascript和HTML避开光标的图像
- JavaScript 如何将鼠标光标更改为图像
- 如何将箭头光标图像更改为我的网页的手形图像
- 如何在 js 和 css3 中使用鼠标光标单击实现滚动图像
- 从 cs 页面更改图像按钮集的光标
- 使用javascript自定义光标图像
- 使用jQuery将光标更改为自定义图像
- 在图像悬停时显示文本而不是光标
- 使用Javascript的随机光标图像
- 在没有画布的javascript中使用自定义光标图像动态更改光标大小
- Javascript-使图像出现在光标处