文本块收缩展开效果

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>文本块收缩展开效果 - 枫叶随风网</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<style>
body {
    margin:0px;
    padding:0px;
}
#main {
    padding-top:20px;
}
#content,#intro{
    margin:0px auto;
    font-size:12px;
    width:200px;
    height:10px;
    line-height:20px;
    background:#eee;
    padding:10px;
    border:4px #ccc double;
    border-bottom:0;
    overflow:hidden;
}
#intro {
    color:#036;
    border:4px #ccc double;
    border-top:0;
    height:30px;
}
#key{
    color:#900;
    float:right;
    cursor:pointer;
}
hr{
    height:1px;
    border:1px #ccc dotted;
}
</style>
<script type="text/javascript">
var s=5;
var minheight=10;
var maxheight=400;
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>
</head>
<body>
<div id="main">
    <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" οnclick="shoppingcat();">展开</span></div>
</div>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值