


Detailed explanation of the exploration of the three effects of accordion in HTML5 applications
Abstract: Accordion (also known as "drawer") effect is named after its expansion style that looks like an accordion. Through hierarchical relationships, a clever balance is achieved in information display and page layout. Therefore, it is widely used in Web and App interaction design. In previous projects, Accordion was usually implemented by JavaScript coding. This sharing focuses on exploring two methods that do not rely on JS and use pure CSS3 or HTML5 to achieve their effects. And make a preliminary comparison of its advantages and disadvantages.
Traditional JS implementation method
1. Native JavaScript
2. Calling JS library files, jQuery, jQuery Mobile
$'.menu_lev1').clickfunction) { var _this=$this), _next=_this.next); if _next.is':visible')) { $'.menu_lev1').removeClass'on'); $'.menu_lev2').slideUp600); _this.addClass'on'); _next.slideDown600); } else { _next.slideUp600); _this.removeClass'on'); } return true; });
Disadvantages of copying code: low efficiency, high cost, behavior and style are tightly coupled.
CSS3 Pseudo-class: target
target is one of new pseudo-classes in CSS3. It can add specified styles to the target element through anchor. Because of the uniqueness of the anchor points in the page, mutually exclusive rotation effects can be achieved.
Sample code 1: h1 first-level directory/h1>
ul id="ac1"> li>二级菜单1/li> li>二级菜单2/li> li>二级菜单3/li> /ul>
Copy code
ul{ display:none;} ul:target{display:block;}
Copy codeExample code 2: c1">First-level directory/a>/ h1>
ul id="ac1"> li>二级菜单1/li> li>二级菜单2/li> li>二级菜单3/li> /ul> h1>2">一级目录/a>/h1> ul id="ac2"> li>二级菜单1/li> li>二级菜单2/li> li>二级菜单3/li> /ul> h1>一级目录/a>/h1> ul id="ac3"> li>二级菜单1/li> li>二级菜单2/li> li>二级菜单3/li> /ul>
Copy code
ul{ display:none;} ul:target{display:block;}
Copy code Sample code 3: div id="ac1" >
h1>a >一级目录/a>span>/span>/h1> ul> li>二级菜单1/li> li>二级菜单2/li> /ul> /div> div id="ac2" > h1>a >一级目录/a>span>/span>/h1> ul> li>二级菜单1/li> li>二级菜单2/li> /ul> /div> div id="ac3" > h1>a 3">一级目录/a>span>/span>/h1> ul> li>二级菜单1/li> li>二级菜单2/li> /ul> /div>
Copy code
ul{-webkit-transition:all ease 1s; } div:target ul{height:400px;} div:target span{-webkit-transform:rotate90deg);}
Copy code Css3 pseudo-class: targetl Disadvantages: 1. No duality. 2. Transition animation height cannot be obtained automatically.
HTML5 tag summary & details
##summary & details. are two new tags in HTML5. In addition to having strong Sample code 1: details>summary>一级目录/summary> ul> li>二级菜单/li> li>二级菜单/li> li>二级菜单/li> /ul> /details>
summary>一级目录/summary> ul> li>二级菜单/li> li>二级菜单/li> li>二级菜单/li> /ul> details> summary>二级菜单/summary> ul> li>三级菜单/li> li>三级菜单/li> li>三级菜单/li> /ul> /details> /details>
details summary::-webkit-details-marker {background: red;color: #fff;font-size: 200%;} summary::-webkit-details-marker { display: none } summary:after { content: "+";} details[open] summary:after {content: "-";}
The above is the detailed content of Detailed explanation of the exploration of the three effects of accordion in HTML5 applications. For more information, please follow other related articles on the PHP Chinese website!

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

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

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

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
