A. html 折疊菜單
<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>
一樣的,用一個大表格,把它們豎向的框起來。
B. 關於C#折疊式的導航菜單
N個BUTTON.N個PANEL.
每個BUTTON對應一個PANEL.
在BUTTON事件里.讓該BUTTON對應的PANEL的Visible=true;
其它的PANEL的Visible=false;
而將要顯示的PANEL位置是根據該BUTTON的位置而定的.代碼如下:
int top=this.button1.Top-this.button1.Height;
int left=this.button1.Left;
this.panel1.Top=top;
this.panel1.Left=left;
this.panel1.Visible=true;
剩下的BUTTON怎麼做.不用我說了吧.
另外要注意的是.在顯示PANEL的時候先去判斷該PANEL當前的狀態.如果已顯示就不執行下面代碼了.
當PANEL顯示時.其下面的BUTTON位置也要變.代碼:
this.button2.Top=this.button2.Top+this.panel1.Height;
還有就是關於滑動的效果.要不要都無所謂.如果非要滑動的話.用線程.每隔一小段時間.讓PANEL和其它BUTTON的位置向算好的數據靠攏.
C. java如何編寫折疊式菜單
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.MutableTreeNode;
public class MainClass extends JPanel {
public static void main(String[] args) {
MutableTreeNode root = new DefaultMutableTreeNode("QQ好友");
MutableTreeNode aNode = new DefaultMutableTreeNode("我的好友");
MutableTreeNode bNode = new DefaultMutableTreeNode("陌生人");
MutableTreeNode cNode = new DefaultMutableTreeNode("黑名單");
root.insert(aNode, 0);
root.insert(bNode, 1);
root.insert(cNode, 2);
aNode.insert(new DefaultMutableTreeNode("friend_a"), 0);
aNode.insert(new DefaultMutableTreeNode("friend_b"), 1);
bNode.insert(new DefaultMutableTreeNode("stranger_a"), 0);
bNode.insert(new DefaultMutableTreeNode("stranger_b"), 1);
cNode.insert(new DefaultMutableTreeNode("black_a"), 0);
cNode.insert(new DefaultMutableTreeNode("black_b"), 1);
DefaultTreeModel model = new DefaultTreeModel(root);
JTree tree = new JTree(model);
JFrame frame = new JFrame("QQ");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new JScrollPane(tree),BorderLayout.NORTH);
frame.pack();
frame.setVisible(true);
}
}
D. html折疊菜單
不太理解你要什麼,看看下面這段代碼實現的效果是你想要的嗎?
<style>div{font-size:12px;color:red; background-color: #EAEAE8; border: 1 solid #1892B5; padding: 1}</style>
<div id="main1" style="color:blue" onclick="document.all.child1.style.display=(document.all.child1.style.display =='none')?'':'none'" >
+ 主目錄</div>
<div id="child1" style="display:none">
<a href="#">- 子目錄1</a> <br>
<a href="#">- 子目錄2</a> <br>
<a href="#">- 子目錄3</a> <br>
<a href="#">- 子目錄4</a>
</div>
<div id="main2" style="color:blue" onclick="document.all.child2.style.display=(document.all.child2.style.display =='none')?'':'none'" >
+ 主目錄2 </div>
<div id="child2" style="display:none">
<a href="#">- 子目錄1</a> <br>
<a href="#">- 子目錄2</a> <br>
<a href="#">- 子目錄3</a>
</div>
E. 求一個 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>
<title>豎向的折疊菜單</title>
<script language = JavaScript>
function showmenu(id) {
var list = document.getElementById("list"+id);
var menu = document.getElementById("menu"+id)
if (list.style.display=="none") {
.getElementById("list"+id).style.display="block";
menu.className = "title1";
}else {
document.getElementById("list"+id).style.display="none";
menu.className = "title";
}
}
</script>
<style type="text/css">
<!--
*{margin:0;padding:0;list-style:none;font-size:14px}
#nav{margin:10px;text-align:center;line-height:25px;width:200px;}
.title{background:#336699;color:#fff;border-bottom:1px solid #fff;cursor:pointer;}
.title1{background:#888;color:#000;border-bottom:1px solid #666;cursor:pointer;}
.content li{color:#336699;background:#ddd;border-bottom:1px solid #fff;}
-->
</style>
</head>
<body>
<div id="nav">
<div class="title" id="menu1" onclick="showmenu('1') ">網站製作</div>
<div id="list1" class="content" style="display:none">
<ul>
<li>div+css</li>
<li>網站設計</li>
<li>網站切圖</li>
</ul>
</div>
<div class="title" id="menu2" onclick="showmenu('2')">網頁代碼</div>
<div id="list2" class="content" style="display:none">
<ul>
<li>菜單導航</li>
<li>層和布局</li>
<li>圖片切換</li>
</ul>
</div>
</div>
</body>
</html>
看是你想要的嗎?