网站首页
无损音乐
高清电影
游戏新闻
动漫资讯
破解资源
站长资源
游戏攻略
JS 实现Div向上浮动的实现代码
网络编程 发布日期:2024/10/11 浏览次数:
1
正在浏览:JS 实现Div向上浮动的实现代码
Html 及 JS 代码如下:
复制代码
代码如下:
<div id="newsOne" onmouseover="CleartTimeInterVal();" onmouseout="resetInterVal();"
style="position: absolute; width: 100px;">
<a href="https://www.jb51.net" target="_blank"></a>
</div>
<script type='text/javascript'>
var newsOne = document.getElementById("newsOne");
newsOne.style.bottom = 0;
newsOne.style.left = window.screen.availWidth - 100;
var bottom = 0;
function newsScroll() {
if (bottom > (window.screen.availHeight - window.screenTop)) {
bottom = 0;
newsOne.style.bottom = 0;
}
else {
bottom = bottom + 15;
newsOne.style.bottom = bottom;
}
}
var timeid = setInterval(newsScroll, 300);
function CleartTimeInterVal() {
clearInterval(timeid);
}
function resetInterVal() {
timeid = setInterval(newsScroll, 300);
}
</script>
在线运行:
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
上一篇:
JS控制按钮自动切换背景颜色(可暂停)
下一篇:
关于JS控制代码暂停的实现方法分享
首页
无损音乐
高清电影
破解资源