JS實(shí)現(xiàn)固定在右下角可展開收縮DIV層的方法
更新時(shí)間:2015年02月13日 12:17:39 作者:代碼家園
這篇文章主要介紹了JS實(shí)現(xiàn)固定在右下角可展開收縮DIV層的方法,右下角的div層可實(shí)現(xiàn)收縮與展開的功能,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了JS實(shí)現(xiàn)固定在右下角可展開收縮DIV層的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
復(fù)制代碼 代碼如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JS實(shí)現(xiàn)固定在右下角可展開收縮的DIV層</title>
<style type="text/css">
<!--
*{margin:0;padding:0;}
body{text-align:center;}
#main{border:red 1px solid;width:1000px;height:1600px;margin:0 auto;}
#main #scroll{width:250px;height:150px;border:green 1px solid;text-align:left;position:absolute;visibility:hidden;}
#main #scroll #open{float:left;text-align:center;width:180px;}
#main #scroll #close{float:right;}
//-->
</style>
</head>
<body>
<div id="main">
僅實(shí)現(xiàn)核心部分,至于內(nèi)容自己完善,或者繼續(xù)美化一下,應(yīng)該不錯(cuò)!
<div id="scroll"><div id="open" onmouseover="openbox()"><a href="/" onclick="openbox()">歡迎光臨</a><div id="close" class="zzsky"><marquee align="left" onmouseover="stop()" onmouseout="start()">歡迎提出寶貴建議!</marquee></div></div>
<div id="close"><a href="#" onclick="closebox()">關(guān)閉</a>
<script type="text/javascript">
<!--
var scroll=document.getElementById("scroll")
var main=document.getElementById("main")
var open=document.getElementById("open")
var close=document.getElementById("close")
scroll.style.visibility="visible"
function runright()
{
/*這里-4主要是為了顯示的比較好,因?yàn)槲以O(shè)置了邊框*/
scroll.style.top=document.body.scrollTop+document.body.clientHeight-scroll.clientHeight-4+"px"
scroll.style.left=document.body.scrollLeft+document.body.clientWidth-scroll.clientWidth-4+"px"
/*隔一段時(shí)間執(zhí)行這個(gè)函數(shù)*/
setTimeout("runright()",30)
}
/*關(guān)閉:設(shè)置高度一直減*/
function closebox()
{
scroll.style.height=scroll.offsetHeight-4+"px"
if (scroll.offsetHeight>20)
{
setTimeout("closebox()",5)
}
else
{
close.style.visibility="hidden"
}
}
function openbox()
{
if (scroll.offsetHeight<148)
{
close.style.visibility="visible"
scroll.style.height=scroll.offsetHeight+2+"px"
setTimeout("openbox()",5)
}
}
runright();
//-->
</script>
</div>
</div>
</div>
</body>
</html>
希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。
您可能感興趣的文章:
- JS+CSS實(shí)現(xiàn)DIV層的展開、收縮效果
- js實(shí)現(xiàn)div層緩慢收縮與展開的方法
- vuejs實(shí)現(xiàn)折疊面板展開收縮動(dòng)畫效果
- JS右下角廣告窗口代碼(可收縮、展開及關(guān)閉)
- JavaScript設(shè)置FieldSet展開與收縮
- 在iframe里的頁面編寫js,實(shí)現(xiàn)在父窗口上創(chuàng)建動(dòng)畫效果展開和收縮的div(不變動(dòng)iframe父窗口代碼)
- JS仿QQ好友列表展開、收縮功能(第一篇)
- JS仿QQ好友列表展開、收縮功能(第二篇)
- Vue.JS實(shí)現(xiàn)垂直方向展開、收縮不定高度模塊的JS組件
- JavaScript實(shí)現(xiàn)QQ列表展開收縮擴(kuò)展功能
- javascript使用substring實(shí)現(xiàn)的展開與收縮文字功能示例
相關(guān)文章
javascript中String對(duì)象的slice()方法分析
這篇文章主要介紹了javascript中String對(duì)象的slice()方法,以實(shí)例形式分析了slice()方法的定義、參數(shù)與具體用法,具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2014-12-12
JavaScript對(duì)象拷貝與賦值操作實(shí)例分析
這篇文章主要介紹了JavaScript對(duì)象拷貝與賦值操作,結(jié)合實(shí)例形式分析了javascript對(duì)象定義、拷貝、賦值等相關(guān)操作技巧與注意事項(xiàng),需要的朋友可以參考下2018-12-12
微信小程序跨頁面?zhèn)鬟fdata數(shù)據(jù)方法解析
這篇文章主要介紹了微信小程序跨頁面?zhèn)鬟fdata數(shù)據(jù)方法解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-12-12
JavaScript控制網(wǎng)頁平滑滾動(dòng)到指定元素位置的方法
這篇文章主要介紹了JavaScript控制網(wǎng)頁平滑滾動(dòng)到指定元素位置的方法,實(shí)例分析了javascript操作頁面滾動(dòng)的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-04-04
location對(duì)象的屬性和方法應(yīng)用(解析URL)
本文將與大家分享下location對(duì)象使用屬性和方法來解析URL的實(shí)例,感興趣的朋友可以參考下,希望對(duì)你有所幫助2013-04-04

