灰儿 发表于 2014-10-14 10:46:39

显示或隐藏左侧列表的html代码

演示效果:

代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>显示或隐藏左侧列表的html代码</title>
<style type="text/css">
body {background:#FFFFFF;color:#000000;font-size:12px;margin:0px;height:100%;}
img {border:none;}
html {height:100%;}
.side {background:url('side_bg.gif') repeat-y;width:180px;}
.side_h {width:8px;background:url('side_hide.gif') no-repeat 0 280px;cursor:pointer;}
.side_s {width:8px;background:url('side_show.gif') no-repeat 0 280px;cursor:pointer;}
</style>
<script type="text/javascript">
function Dd(i) {return document.getElementById(i);}
function Ds(i) {Dd(i).style.display = '';}
function Dh(i) {Dd(i).style.display = 'none';}
function oh(o) {
        if(o.className == 'side_h') {
                Dh('side');o.className = 'side_s';
        } else {
                Ds('side');o.className = 'side_h';
        }
}
</script>
</head>
<body>
<table width="100%" height="200" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" class="side" id="side">left</td>
<td class="side_h" id="side_oh" title="显示隐藏开关"> </td>
<td valign="top" class="main" id="main">right</td>
</tr>
</table>

<script type="text/javascript">
if(document.body.clientHeight > Dd('main').scrollHeight) Dd('main').style.height=document.body.clientHeight+'px';
</script>
</body>
</html>






灰儿 发表于 2014-10-14 14:31:55

如果需要默认不显示左侧列表,可以查找如下代码:
<td valign="top" class="side" id="side">


改为:
<td valign="top" class="side" id="side" style="display:none">
页: [1]
查看完整版本: 显示或隐藏左侧列表的html代码