div動態展開和關閉

來源:互聯網
上載者:User
<style>  
#content,#intro{  
    font: 13px/25px;  
    width: 200px;  
    height: 40px;  
    background: #eee;  
    padding: 10px;  
    border: 4px #ccc double;  
        border-bottom:0;  
    overflow: hidden;  
}  
 
#intro {  
    color: #036;  
    font:12px;  
        border: 4px #ccc double;  
        border-top:0;  
        height:70px;  
}  
#key{color:#900;float:right}  
hr{height:1px;border:1px #ccc dotted}  
</style>  
<script>  
var s=5;  
var minheight=40;  
var maxheight=500;  
function shoppingcat(){  
    var key = document.getElementById("key").innerText;  
    if(key=="展開"){  
        content.style.pixelHeight+=s;  
        if(content.style.pixelHeight<maxheight){  
            setTimeout("shoppingcat();",1);  
        }else{  
            document.getElementById("key").innerText="關閉";  
        }  
    }else{  
        content.style.pixelHeight-=s;  
        if(content.style.pixelHeight>minheight){  
            setTimeout("shoppingcat();",1);  
        }else{  
            document.getElementById("key").innerText="展開";  
        }  
    }  
}  
</script>  
<div id="content">   
孤雁兒  
<br><br>  
世人作梅詞,下筆便俗。予試作一篇,乃知前言不妄耳。<br><br>  
藤床紙帳朝眠起,<br>   
說不盡、無佳思。<br>  
沈香煙斷玉爐寒,<br>  
伴我情懷如水。<br>  
笛聲三弄,<br>  
梅心驚破,<br>  
多少春情意。<br><br>  
 
小風疏雨蕭蕭地,<br>  
又催下、千行淚。<br>  
吹簫人去玉樓空,<br>   
腸斷與誰同倚?  
一枝折得,<br>  
人間天上,<br>  
沒個人堪寄。  
</div>  
 
<div id="intro" ><hr>作者:李清照<span id="key" onclick="shoppingcat();">展開</span><br>來源:中國詩辭網</div>  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.