JS 實現(xiàn)Div向上浮動的實現(xiàn)代碼
更新時間:2012年10月11日 23:10:53 作者:
用js實現(xiàn)的可以讓div慢慢上升效果實現(xiàn)代碼,喜歡的朋友可以參考下
Html 及 JS 代碼如下:
<div id="newsOne" onmouseover="CleartTimeInterVal();" onmouseout="resetInterVal();"
style="position: absolute; width: 100px;">
<a href="http://www.dbjr.com.cn" 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需再刷新一下頁面才能執(zhí)行]
復(fù)制代碼 代碼如下:
<div id="newsOne" onmouseover="CleartTimeInterVal();" onmouseout="resetInterVal();"
style="position: absolute; width: 100px;">
<a href="http://www.dbjr.com.cn" 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需再刷新一下頁面才能執(zhí)行]
相關(guān)文章
JavaScript利用虛擬列表實現(xiàn)高性能渲染數(shù)據(jù)詳解
在前文中我們提到可以使用時間分片的方式來對長列表進(jìn)行渲染,但這種方式更適用于列表項的DOM結(jié)構(gòu)十分簡單的情況,所以本文來講講如何使用虛擬列表的方式,來同時加載大量數(shù)據(jù)吧2023-05-05JS數(shù)組的遍歷方式for循環(huán)與for...in
本節(jié)主要介紹了JS數(shù)組的遍歷方式for循環(huán)與for...in,需要的朋友可以參考下2014-07-07如何將一個String和多個String值進(jìn)行比較思路分析
開發(fā)中我們經(jīng)常需要將一個String和多個String值進(jìn)行比較。直覺反應(yīng)是使用||符號連接多個===完成,感興趣的朋友可以了解下哈2013-04-04javascript實現(xiàn)導(dǎo)航欄分頁效果
這篇文章主要為大家詳細(xì)介紹了javascript實現(xiàn)導(dǎo)航欄分頁效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-06-06JavaScript中關(guān)于Object.create()的用法
這篇文章主要介紹了JavaScript中關(guān)于Object.create()的用法,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-02-02