


Complete example of implementing TreeMenu secondary tree menu using JS CSS_javascript skills
The example in this article describes the implementation of TreeMenu secondary tree menu with JS CSS. Share it with everyone for your reference. The details are as follows:
This is an example of a two-level tree menu: CSS TreeMenu, a very beautiful tree menu, which is more suitable for use on the right side of the website.
The screenshot of the running effect is as follows:
The online demo address is as follows:
http://demo.jb51.net/js/2015/js-css-treemenu-2l-menu-codes/
The specific code is as follows:
<!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="gb2312"> <head> <title>二级树形菜单示例:CSS TreeMenu</title> <style type="text/css" media="all"> a,a:visited {color:#333;text-decoration:none;} a:hover {color:#f60;} body,td {font:13px "Geneva","宋体", "Arial", "Helvetica",sans-serif;} ul,li {margin:0;padding:0;list-style:none;} h1,h2,h3,h4,h5,h6 {margin:0;padding:0;} h1 {padding:5px;color:#900;font:16px bold "Geneva","宋体", "Arial", "Helvetica",sans-serif;} h1 small {font-size:11px;font-weight:normal;color:#660;} .TreeWrap {width:200px;} .MenuBox .titBox a, .MenuBox .titBox a:visited, .MenuBox2 .titBox a, .MenuBox2 .titBox a:visited {margin-left:10px;padding-left:40px;color:#003;font-size:12px;display:block;} .MenuBox .titBox h3 a {background:url(images/ico_folder_open.gif) no-repeat 0 40%;} .MenuBox .titBox h3.Fst a {background:url(images/ico_folder_open_fst.gif) no-repeat 0 40%;} .MenuBox .titBox h3.Lst a {background:url(images/ico_folder_open_lst.gif) no-repeat 0 40%;} .MenuBox2 .titBox h3 a {background:url(images/ico_folder.gif) no-repeat 0 40%;} .MenuBox2 .titBox h3.Fst a {background:url(images/ico_folder_fst.gif) no-repeat 0 40%;} .MenuBox2 .titBox h3.Lst a {line-height:250%;background:url(images/icon_exit.gif) no-repeat 0 0;} .MenuBox2 .txtBox {display:none;} .MenuBox .txtBox ul li {padding-left:65px;line-height:150%;} .MenuBox .txtBox .num {color:#e00;} .MenuBox .txtBox ul {background:url(images/line_y.gif) repeat-y 16px 0;} .MenuBox .txtBox ul li {background:url(images/t.gif) no-repeat 28px 50%;} .MenuBox .txtBox ul li.Lst {background:url(images/t_lst.gif) no-repeat 28px 50%;} </style> <script type="text/javascript"> <!-- function ExChgClsName(Obj,NameA,NameB){ var Obj=document.getElementById(Obj)?document.getElementById(Obj):Obj; Obj.className=Obj.className==NameA?NameB:NameA; } function showMenu(iNo){ ExChgClsName("Menu_"+iNo,"MenuBox","MenuBox2"); } --> </script> </head> <body> <h1>CSS TreeMenu <small>By 枫岩@IECN.Net</small></h1> <div class="TreeWrap"> <div class="MenuBox" id="Menu_0"> <div class="titBox"><h3 class="Fst"><a href="javascript:showMenu(0);">同事</a></h3></div> <div class="txtBox"> <ul> <li><a href="#">Dodo</a></li> <li><a href="#">小春</a></li> <li><a href="#">小林</a></li> <li><a href="#">小龙</a></li> <li class="Lst"><a href="#">枫岩</a></li> </ul> </div> </div><!--MenuBox--> <div class="MenuBox2" id="Menu_1"> <div class="titBox"><h3><a href="javascript:showMenu(1);">客户</a></h3></div> <div class="txtBox"> <ul> <li><a href="#">Dodo</a></li> <li><a href="#">小春</a></li> <li><a href="#">小林</a></li> <li><a href="#">小龙</a></li> <li class="Lst"><a href="#">枫岩</a></li> </ul> </div> </div><!--MenuBox--> <div class="MenuBox2" id="Menu_2"> <div class="titBox"><h3><a href="javascript:showMenu(2);">朋友</a></h3></div> <div class="txtBox"> <ul> <li><a href="#">Dodo</a></li> <li><a href="#">小春</a></li> <li><a href="#">小林</a></li> <li><a href="#">小龙</a></li> <li class="Lst"><a href="#">枫岩</a></li> </ul> </div> </div><!--MenuBox--> <div class="MenuBox2" id="Menu_3"> <div class="titBox"><h3><a href="javascript:showMenu(3);">家人</a></h3></div> <div class="txtBox"> <ul> <li><a href="#">Dodo</a></li> <li><a href="#">小春</a></li> <li><a href="#">小林</a></li> <li><a href="#">小龙</a></li> <li class="Lst"><a href="#">枫岩</a></li> </ul> </div> </div><!--MenuBox--> <div class="MenuBox2"> <div class="titBox"><h3 class="Lst"><a href="#">退出系统</a></h3></div> </div><!--MenuBox--> </div> </body> </html>
I hope this article will be helpful to everyone’s JavaScript programming.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-

There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

Answer: You can use the date picker component of Bootstrap to view dates in the page. Steps: Introduce the Bootstrap framework. Create a date selector input box in HTML. Bootstrap will automatically add styles to the selector. Use JavaScript to get the selected date.

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

To verify dates in Bootstrap, follow these steps: Introduce the required scripts and styles; initialize the date selector component; set the data-bv-date attribute to enable verification; configure verification rules (such as date formats, error messages, etc.); integrate the Bootstrap verification framework and automatically verify date input when form is submitted.

Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.
