html表格可折叠的三级分类是什么?

html表格可折叠的三级分类是什么?,第1张

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=UTF-8" />

<title>CSS+JavaScript三级折叠菜单</title>

<style>

*,body,ul,li,h1,h2 {

margin: 0

padding: 0

list-style: none

}

body {

font: 12px "宋体"

padding-top: 20px

}

#menu {

width: 200px

margin: auto

}

#menu h1 {

cursor: pointer

color: #FFF

font-size: 12px

padding: 5px 0 3px 10px

border: #C60 1px solid

margin-top: 1px

background-color: #F93

}

#menu h2 {

cursor: pointer

color: #777

font-size: 12px

padding: 5px 0 3px 10px

border: #E7E7E7 1px solid

border-top-color: #FFF

background-color: #F4F4F4

}

#menu ul {

padding-left: 15px

height: 100px

border: #E7E7E7 1px solid

border-top: none

overflow: auto

}

#menu ul li {

padding: 5px 0 3px 10px

}

.no {

display: none

}

</style>

<script language="JavaScript">

function ShowMenu(obj, noid) {

var block = document.getElementById(noid)

var n = noid.substr(noid.length - 1)

if (noid.length == 4) {

var ul = document.getElementById(noid.substring(0, 3)).getElementsByTagName("ul")

var h2 = document.getElementById(noid.substring(0, 3)).getElementsByTagName("h2")

for (var i = 0i <h2.lengthi++) {

h2[i].innerHTML = h2[i].innerHTML.replace("+", "-")

h2[i].style.color = ""

}

obj.style.color = "#FF0000"

for (var i = 0i <ul.lengthi++) {

if (i != n) {

ul[i].className = "no"

}

}

} else {

var span = document.getElementById("menu").getElementsByTagName("span")

var h1 = document.getElementById("menu").getElementsByTagName("h1")

for (var i = 0i <h1.lengthi++) {

h1[i].innerHTML = h1[i].innerHTML.replace("+", "-")

h1[i].style.color = ""

}

obj.style.color = "#0000FF"

for (var i = 0i <span.lengthi++) {

if (i != n) {

span[i].className = "no"

}

}

}

if (block.className == "no") {

block.className = ""

obj.innerHTML = obj.innerHTML.replace("-", "+")

} else {

block.className = "no"

obj.style.color = ""

}

}

</script>

</head>

<body>

<div id="menu">

<h1 onClick="javascript:ShowMenu(this,'NO0')">- 一级菜单A</h1>

<span id="NO0" class="no">

<h2 onClick="javascript:ShowMenu(this,'NO00')">- 一级菜单A_1</h2>

<ul id="NO00" class="no">

<li>一级菜单A_0</li>

<li>一级菜单A_1</li>

<li>一级菜单A_2</li>

<li>一级菜单A_3</li>

<li>一级菜单A_4</li>

<li>一级菜单A_5</li>

</ul>

<h2 onClick="javascript:ShowMenu(this,'NO01')">- 一级菜单A_2</h2>

<ul id="NO01" class="no">

<li>一级菜单A_0</li>

<li>一级菜单A_1</li>

<li>一级菜单A_2</li>

<li>一级菜单A_3</li>

<li>一级菜单A_4</li>

</ul>

<h2 onClick="javascript:ShowMenu(this,'NO02')">- 一级菜单A_3</h2>

<ul id="NO02" class="no">

<li>一级菜单A_0</li>

<li>一级菜单A_1</li>

<li>一级菜单A_2</li>

<li>一级菜单A_3</li>

<li>一级菜单A_4</li>

<li>一级菜单A_5</li>

<li>一级菜单A_6</li>

</ul>

<h2 onClick="javascript:ShowMenu(this,'NO03')">- 一级菜单A_4</h2>

<ul id="NO03" class="no">

<li>一级菜单A_0</li>

<li>一级菜单A_1</li>

<li>一级菜单A_2</li>

<li>一级菜单A_3</li>

<li>一级菜单A_4</li>

<li>一级菜单A_5</li>

<li>一级菜单A_6</li>

<li>一级菜单A_7</li>

</ul>

</span>

<h1 onClick="javascript:ShowMenu(this,'NO1')">- 二级菜单B</h1>

<span id="NO1" class="no">

<h2 onClick="javascript:ShowMenu(this,'NO10')">- 二级菜单B_1</h2>

<ul id="NO10" class="no">

<li>二级菜单B_0</li>

<li>二级菜单B_1</li>

<li>二级菜单B_2</li>

<li>二级菜单B_3</li>

<li>二级菜单B_4</li>

<li>二级菜单B_5</li>

<li>二级菜单B_6</li>

<li>二级菜单B_7</li>

</ul>

<h2 onClick="javascript:ShowMenu(this,'NO11')">- 二级菜单B_2</h2>

<ul id="NO11" class="no">

<li>二级菜单B_0</li>

<li>二级菜单B_1</li>

<li>二级菜单B_2</li>

<li>二级菜单B_3</li>

<li>二级菜单B_4</li>

<li>二级菜单B_5</li>

<li>二级菜单B_6</li>

<li>二级菜单B_7</li>

</ul>

</span>

<h1 onClick="javascript:ShowMenu(this,'NO2')">- 三级菜单C</h1>

<span id="NO2" class="no">

<h2 onClick="javascript:ShowMenu(this,'NO20')">- 三级菜单C_1</h2>

<ul id="NO20" class="no">

<li>三级菜单C_0</li>

<li>三级菜单C_1</li>

<li>三级菜单C_2</li>

<li>三级菜单C_3</li>

<li>三级菜单C_4</li>

<li>三级菜单C_5</li>

<li>三级菜单C_6</li>

<li>三级菜单C_7</li>

<li>三级菜单C_8</li>

<li>三级菜单C_9</li>

</ul>

<h2 onClick="javascript:ShowMenu(this,'NO21')">- 三级菜单C_2</h2>

<ul id="NO21" class="no">

<li>三级菜单C_0</li>

<li>三级菜单C_1</li>

<li>三级菜单C_2</li>

<li>三级菜单C_3</li>

<li>三级菜单C_4</li>

</ul>

</span>

<h1 onClick="javascript:ShowMenu(this,'NO3')">- 四级菜单D</h1>

<span id="NO3" class="no">

<h2 onClick="javascript:ShowMenu(this,'NO30')">- 四级菜单D_1</h2>

<ul id="NO30" class="no">

<li>四级菜单D_0</li>

<li>四级菜单D_1</li>

<li>四级菜单D_2</li>

<li>四级菜单D_3</li>

</ul>

<h2 onClick="javascript:ShowMenu(this,'NO31')">- 四级菜单D_2</h2>

<ul id="NO31" class="no">

<li>四级菜单D_0</li>

<li>四级菜单D_1</li>

<li>四级菜单D_2</li>

<li>四级菜单D_3</li>

<li>四级菜单D_4</li>

<li>四级菜单D_5</li>

</ul>

</span>

</div>

</body>

</html>

用html和css实现标签折叠,代码如下:

<!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/htmlcharset=gb2312" />

<title>用html和css实现标签折叠</title>

</head>

<body>

<ul id="fm">

      <li><a href="#"><h1>折叠标签A</h1>

          <span>这里是描述标签A</span>

<span>这里是描述标签A</span>

<span>这里是描述标签A</span>

</a></li>

      <li><a href="#"><h1>折叠标签B</h1>

          <span>这里是描述标签B</span>

<span>这里是描述标签B</span>

<span>这里是描述标签B</span></a>

      <li><a href="#"><h1>折叠标签C</h1>

          <span>这里是描述标签C</span>

<span>这里是描述标签C</span>

<span>这里是描述标签C</span></a>

<li><a href="#"><h1>折叠标签D</h1>

          <span>这里是描述标签D</span>

<span>这里是描述标签D</span>

<span>这里是描述标签D</span></a>

  </ul>

</body>

</html>

CSS样式为:

<style type="text/css">

#fm{

  overflow:hidden

  background-color:#FFCCCC

  width:200px

  height:500px

  overflow:hidden

}

#fm h1{

  margin:0px

  color:#FF3333

  font-size:14px

}

#fm li{

  list-sytle-type:none

  display:block

  width:178px

  border:1px solid #00CCCC

  border-bottom-width:0px

}

#fm li.end{

  border-bottom-width:1px

}

#fm li a{

  display:block

  text-decoration:none

  width:100%

  padding:10px

}

#fm li a span{

  display:none

  color:#000000

  font-size:12px

  padding-top:10px

}

#fm li a:hover{

  background:#fff

}

#fm li a:hover span{

  display:block

  cursor:hand

}

</style>

效果如图:

以上就是用html和css实现标签折叠的解决方法。

<table border="0" cellspacing="0" cellpadding="0">

<tr>

<td scope="row"><table border="1">

<tr>

<td id="showbfq" height="20" align="top" onclick="if(bfq.style.display=='none'){bfq.style.display=''showbfq.innerText='优质'}

else{bfq.style.display='none'showbfq.innerText='点击更多'}">点击更多</td>

</tr>

<tr>

<td height="80" align="center" name="bfq" id="bfq" style="display:none">aaa</td>

</tr>

</table></td></tr>

<tr><td><table border="1">

<tr>

<td id="showbfq1" height="20" align="top" onclick="if(bfq1.style.display=='none'){bfq1.style.display=''showbfq1.innerText='优质'}

else{bfq1.style.display='none'showbfq1.innerText='点击更多'}">点击更多</td>

</tr>

<tr>

<td height="80" align="center" name="bfq1" id="bfq1" style="display:none">bbb</td>

</tr>

</table></td></tr>

<tr><td><table border="1">

<tr>

<td id="showbfq2" height="20" align="top" onclick="if(bfq2.style.display=='none'){bfq2.style.display=''showbfq2.innerText='优质'}

else{bfq2.style.display='none'showbfq2.innerText='点击更多'}">点击更多</td>

</tr>

<tr>

<td height="80" align="center" name="bfq2" id="bfq2" style="display:none">ccc</td>

</tr>

</table></td></tr>

</table>

一样的,用一个大表格,把它们竖向的框起来。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/6129939.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-15
下一篇 2023-03-15

发表评论

登录后才能评论

评论列表(0条)

保存