Home Web Front-end JS Tutorial Complete implementation method of JavaScript+CSS Infinitus classification effect_javascript skills

Complete implementation method of JavaScript+CSS Infinitus classification effect_javascript skills

May 16, 2016 pm 03:24 PM
css javascript Infinitus Classification

The example in this article describes the complete implementation method of JavaScript+CSS Infinitus classification effect. Share it with everyone for your reference, the details are as follows:

CSS style:

a {text-decoration:none;}
a,a:visited {color:#000;background:inherit;}
body {margin:0;padding:20px;font:12px tahoma,宋体,sans-serif;}
dt {font-size:22px;font-weight:bold;margin:0 0 0 15px;}
dd {margin:0 0 0 15px;}
h4 {margin:0;padding:0;font-size:18px;text-align:center;}
p {margin:0;padding:0 0 0 18px;}
p a,p a:visited {color:#00f;background:inherit;}
/*CNLTreeMenu Start*/
.CNLTreeMenu img.s {cursor:pointer;vertical-align:middle;}
.CNLTreeMenu ul {padding:0;}
.CNLTreeMenu li {list-style:none;padding:0;}
.Closed ul {display:none;}
.Child img.s {background:none;cursor:default;}
#CNLTreeMenu1 ul {margin:0 0 0 17px;}
#CNLTreeMenu1 img.s {width:20px;height:15px;}
#CNLTreeMenu1 .Opened img.s {background:url(skin1/opened.gif) no-repeat 0 0;}
#CNLTreeMenu1 .Closed img.s {background:url(skin1/closed.gif) no-repeat 0 0;}
#CNLTreeMenu1 .Child img.s {background:url(skin1/child.gif) no-repeat 3px 5px;}
#CNLTreeMenu2 ul {margin:0 0 0 17px;}
#CNLTreeMenu2 img.s {width:17px;height:15px;}
#CNLTreeMenu2 .Opened img.s {background:url(skin2/opened.gif) no-repeat 4px 6px;}
#CNLTreeMenu2 .Closed img.s {background:url(skin2/closed.gif) no-repeat 3px 6px;}
#CNLTreeMenu2 .Child img.s {background:url(skin2/child.gif) no-repeat 3px 5px;}
#CNLTreeMenu3 ul {margin:0 0 0 17px;}
#CNLTreeMenu3 img.s {width:34px;height:18px;}
#CNLTreeMenu3 .Opened img.s {background:url(skin3/opened.gif) no-repeat 0 1px;}
#CNLTreeMenu3 .Closed img.s {background:url(skin3/closed.gif) no-repeat 0 1px;}
#CNLTreeMenu3 .Child img.s {background:url(skin3/child.gif) no-repeat 13px 2px;}
/*CNLTreeMenu End*/
/*Temp CSS for View Demo*/
#CNLTreeMenu1,#CNLTreeMenu2,#CNLTreeMenu3 {float:left;width:249px;border:1px solid #99BEEF;background:#D2E4FC;color:inherit;margin:3px;padding:3px;}
#CNLTreeMenu1,#CNLTreeMenu2 {padding-bottom:15px;}
.ViewCode {
 clear:both;
 border:1px solid #FFB900;background:#FFFFCC;color:inherit;margin:3px;padding:3px;
}
.ViewCode h6 {color:#00f;}

Copy after login

JavaScript code:

function Ob(o){
 var o=document.getElementById(o)?document.getElementById(o):o;
 return o;
}
function Hd(o) {
 Ob(o).style.display="none";
}
function Sw(o) {
 Ob(o).style.display="";
}
function ExCls(o,a,b,n){
 var o=Ob(o);
 for(i=0;i<n;i++) {o=o.parentNode;}
 o.className=o.className==a&#63;b:a;
}
function CNLTreeMenu(id,TagName0) {
 this.id=id;
 this.TagName0=TagName0==""&#63;"li":TagName0;
 this.AllNodes = Ob(this.id).getElementsByTagName(TagName0);
 this.InitCss = function (ClassName0,ClassName1,ClassName2,ImgUrl) {
 this.ClassName0=ClassName0;
 this.ClassName1=ClassName1;
 this.ClassName2=ClassName2;
 this.ImgUrl=ImgUrl || "css/s.gif";
 this.ImgBlankA ="<img src=\""+this.ImgUrl+"\" class=\"s\" onclick=\"ExCls(this,'"+ClassName0+"','"+ClassName1+"',1);\" alt=\"展开/折叠\" />";
 this.ImgBlankB ="<img src=\""+this.ImgUrl+"\" class=\"s\" />";
 for (i=0;i<this.AllNodes.length;i++ ) {
  this.AllNodes[i].className==""&#63;this.AllNodes[i].className=ClassName1:"";
  this.AllNodes[i].innerHTML=(this.AllNodes[i].className==ClassName2&#63;this.ImgBlankB:this.ImgBlankA)+this.AllNodes[i].innerHTML;
  }
 }
 this.SetNodes = function (n) {
 var sClsName=n==0&#63;this.ClassName0:this.ClassName1;
 for (i=0;i<this.AllNodes.length;i++ ) {
  this.AllNodes[i].className==this.ClassName2&#63;"":this.AllNodes[i].className=sClsName;
 }
 }
}

Copy after login

HTML page:

<!--CNLTreeMenu Start:-->
<div class="CNLTreeMenu" id="CNLTreeMenu1">
<h4>CNL Tree Menu1</h4>
<p><a id="AllOpen_1" href="#" onclick="MyCNLTreeMenu1.SetNodes(0);Hd(this);Sw('AllClose_1');">全部展开</a><a id="AllClose_1" href="#" onclick="MyCNLTreeMenu1.SetNodes(1);Hd(this);Sw('AllOpen_1');" style="display:none;">全部折叠</a></p>
<ul>
 <li class="Opened"><a href="http://www.jb51.net">JB51.Net</a>
 <ul>
  <li><a href="#1">技术区</a>
   <ul>
    <li><a href="#">网页技术</a>
    <ul>
     <li class="Child"><a href="#">JavaScript</a></li><!--Child Node-->
     <li class="Child"><a href="#">HTML/XHTML/CSS</a></li>
     <li class="Child"><a href="#">Ajax</a></li>
     <li class="Child"><a href="#">网页制作工具</a></li>
     <li class="Child"><a href="#">设计/图形</a></li>
     <li class="Child"><a href="#">Flash/多媒体</a></li>
     <li class="Child"><a href="#">VML/Web3D</a></li>
    </ul></li><!--Sub Node 3-->
    <li><a href="#">Web编程</a>
    <ul>
     <li class="Child"><a href="#">Java</a></li><!--Child Node-->
     <li class="Child"><a href="#">.Net</a></li>
     <li class="Child"><a href="#">ASP/VBScript</a></li>
     <li class="Child"><a href="#">PHP</a></li>
     <li class="Child"><a href="#">Perl/Python</a></li>
     <li class="Child"><a href="#">Web综合/开源</a></li>
    </ul></li><!--Sub Node 3-->
    <li><a href="#">数据库</a>
    <ul>
     <li class="Child"><a href="#">Access/SQLServer</a></li><!--Child Node-->
     <li class="Child"><a href="#">MySQL/PostgreSQL</a></li>
     <li class="Child"><a href="#">Oracle/DB2/Sybase</a></li>
    </ul></li><!--Sub Node 3-->
    <li><a href="#">服务器</a>
    <ul>
     <li class="Child"><a href="#">Windows/IIS</a></li><!--Child Node-->
     <li class="Child"><a href="#">Unix/Linux/Apache</a></li>
     <li class="Child"><a href="#">应用服务器</a></li>
    </ul></li><!--Sub Node 3-->
   </ul></li><!--Sub Node 2-->
  <li><a href="#1">二级目录</a>
   <ul>
    <li><a href="#">三级目录</a>
    <ul>
     <li><a href="#">四级目录</a>
     <ul>
      <li><a href="#">五级目录</a>
      <ul>
       <li><a href="#"></a>
       <ul>
        <li><a href="#">第n级目录</a>
         <ul>
          <li class="Child"><a href="#">叶结点1</a></li><!--Child Node-->
          <li class="Child"><a href="#">叶结点2</a></li>
          <li class="Child"><a href="#">叶结点3</a></li>
          </ul></li><!--Sub Node n -->
       </ul></li><!--Sub Node 6 -->
      </ul></li><!--Sub Node 5 -->
     </ul></li><!--Sub Node 4-->
    </ul></li><!--Sub Node 3-->
   </ul></li><!--Sub Node 2-->
  <li><a href="#1">二级目录</a>
   <ul>
    <li><a href="#">三级目录</a>
    <ul>
     <li><a href="#">四级目录</a>
     <ul>
      <li><a href="#">五级目录</a>
      <ul>
       <li><a href="#"></a>
       <ul>
        <li><a href="#">第n级目录</a>
         <ul>
          <li class="Child"><a href="#">叶结点1</a></li><!--Child Node-->
          <li class="Child"><a href="#">叶结点2</a></li>
          <li class="Child"><a href="#">叶结点3</a></li>
          </ul></li><!--Sub Node n -->
       </ul></li><!--Sub Node 6 -->
      </ul></li><!--Sub Node 5 -->
     </ul></li><!--Sub Node 4-->
    </ul></li><!--Sub Node 3-->
   </ul></li><!--Sub Node 2-->
 </ul></li><!--Sub Node 1 -->
</ul>
</div><!-- CNLTreeMenu -->
<!--CNLTreeMenu1 End!-->

Copy after login

I hope this article will be helpful to everyone in JavaScript programming.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use bootstrap in vue How to use bootstrap in vue Apr 07, 2025 pm 11:33 PM

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.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

How to set up the framework for bootstrap How to set up the framework for bootstrap Apr 07, 2025 pm 03:27 PM

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.

How to write split lines on bootstrap How to write split lines on bootstrap Apr 07, 2025 pm 03:12 PM

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.

How to insert pictures on bootstrap How to insert pictures on bootstrap Apr 07, 2025 pm 03:30 PM

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.

How to use bootstrap button How to use bootstrap button Apr 07, 2025 pm 03:09 PM

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

How to resize bootstrap How to resize bootstrap Apr 07, 2025 pm 03:18 PM

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-

See all articles