JS 實(shí)現(xiàn)Div向上浮動(dòng)的實(shí)現(xiàn)代碼
更新時(shí)間:2012年10月11日 23:10:53 作者:
用js實(shí)現(xiàn)的可以讓div慢慢上升效果實(shí)現(xiàn)代碼,喜歡的朋友可以參考下
Html 及 JS 代碼如下:
<div id="newsOne" onmouseover="CleartTimeInterVal();" onmouseout="resetInterVal();"
style="position: absolute; width: 100px;">
<a href="http://www.fzitv.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>
在線運(yùn)行:
[Ctrl+A 全選 注:引入外部Js需再刷新一下頁面才能執(zhí)行]
復(fù)制代碼 代碼如下:
<div id="newsOne" onmouseover="CleartTimeInterVal();" onmouseout="resetInterVal();"
style="position: absolute; width: 100px;">
<a href="http://www.fzitv.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>
在線運(yùn)行:
[Ctrl+A 全選 注:引入外部Js需再刷新一下頁面才能執(zhí)行]
您可能感興趣的文章:
- JS實(shí)現(xiàn)彈出浮動(dòng)窗口(支持鼠標(biāo)拖動(dòng)和關(guān)閉)實(shí)例詳解
- JS實(shí)現(xiàn)可縮放、拖動(dòng)、關(guān)閉和最小化的浮動(dòng)窗口完整實(shí)例
- js實(shí)現(xiàn)網(wǎng)站最上邊可關(guān)閉的浮動(dòng)廣告條代碼
- JS實(shí)現(xiàn)側(cè)懸浮浮動(dòng)實(shí)例代碼
- js浮動(dòng)圖片的動(dòng)態(tài)效果
- js頁面滾動(dòng)時(shí)層智能浮動(dòng)定位實(shí)現(xiàn)(jQuery/MooTools)
- JS模擬Dialog彈出浮動(dòng)框效果代碼
相關(guān)文章
javascript設(shè)置連續(xù)兩次點(diǎn)擊按鈕時(shí)間間隔的方法
這篇文章主要介紹了javascript設(shè)置連續(xù)兩次點(diǎn)擊按鈕時(shí)間間隔的方法,是非常實(shí)用的技巧,需要的朋友可以參考下2014-10-10
基于JavaScript繪制動(dòng)態(tài)花束的示例代碼
p5.js 是一個(gè)JavaScript的函數(shù)庫(kù),它在制作之初就和Processing有同樣的目標(biāo)。本文將利用p5.js 制作出一束動(dòng)態(tài)花束,感興趣的可以嘗試一下2022-06-06
用JavaScript來美化HTML的select標(biāo)簽的下拉列表效果
這篇文章主要介紹了用JavaScript來美化HTML的select標(biāo)簽的下拉列表效果的方法,而且在多瀏覽器下的兼容效果也得到提升,需要的朋友可以參考下2015-11-11
工作中常用的js、jquery自定義擴(kuò)展函數(shù)代碼片段匯總
本文主要對(duì)工作中常用的js、jquery自定義擴(kuò)展函數(shù)代碼片段進(jìn)行了分享,具有很好的參考價(jià)值,需要的朋友一起來看下吧2016-12-12
使用wxapp-img-loader自定義組件實(shí)現(xiàn)微信小程序圖片預(yù)加載功能
由于微信小程序沒有提供類似 Image 這樣的 JS 對(duì)象,要實(shí)現(xiàn)圖片的預(yù)加載要麻煩一些,wxapp-img-loader自定義組件可以在微信小程序中實(shí)現(xiàn)圖片預(yù)加載功能,需要的朋友可以參考下2018-10-10
JavaScript中Array數(shù)組常用方法(附上相應(yīng)的用法及示例)
這篇文章主要給大家介紹了關(guān)于JavaScript中Array數(shù)組常用方法,文中附上相應(yīng)的用法及示例,需要的朋友可以參考下2024-01-01
微信小程序?qū)崿F(xiàn)頁面浮動(dòng)導(dǎo)航
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)頁面浮動(dòng)導(dǎo)航,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-01-01

