HTML6 implements folding menu and accordion menu example code

HTML6 implements folding menu and accordion menu example code

The main part of the page:

<body> <ul id="menu">
          <li>   
                 <a href="#">First level menu 1</a>
                 <ul>
                        <li>Secondary Menu 1-1</li>
                        <li>Secondary Menu 1-2</li>
                        <li>Secondary Menu 1-3</li>
                 </ul>       
          </li>
          <li>    
                  <a href="#">First Level Menu 2</a>
                  <ul>
                        <li>Secondary Menu 2-1</li>
                        <li>Secondary Menu 2-2</li>
                        <li>Secondary Menu 2-3</li>
                  </ul>   
          </li>
          <li>
                  <a href="#">First level menu 3</a>
                  <ul>
                        <li>Secondary Menu 3-1</li>
                        <li>Secondary Menu 3-2</li>
                        <li>Secondary Menu 3-3</li>
                  </ul> 
          </li>
          <li>
                  <a href="#">First level menu 4</a>
                  <ul>
                        <li>Secondary Menu 4-1</li>
                        <li>Secondary Menu 4-2</li>
                        <li>Secondary Menu 4-3</li>
                  </ul> 
          </li>
  <ul>
</body>

Folding menu example:

CSS part

<head>
<style type="text/css">
li{
    list-style:none; remove the graphics in front of the list}
li a{
    color:#123; Set the first level menu text color}
#menu ul{
    display:none; Set the secondary menu not to be displayed by default}
#menu>li:hover ul{
    display:block; When the mouse moves over the first-level menu, the second-level menu is displayed}
</style>
</head>

Accordion menu example:

CSS part

<head>
<style type="text/css">
li{
    list-style:none; remove the graphics in front of the list}
li a{
    color:#123; Set the first level menu text color}
#menu>li,#menu>li>a,#menu>li>ul{
    float:left; first level menu, second level menu moves left}
#menu>li>a{
    display:block;
    background-color;red;    
}
#menu>li:hover ul{
    display:block;
}
#menu>ul{
     display:none;
     width:100px;
     background-color:#123 ;
     padding-top:20px;
}
</style>
</head>

Summarize

The above is the example code of HTML6 implementing folding menu and accordion menu introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

<<:  Using CSS3 to create header animation effects

>>:  Web page header optimization suggestions

Recommend

Installation and use of mysql mycat middleware

1. What is mycat A completely open source large d...

Basic use of subqueries in MySQL

Table of contents 1. Subquery definition 2. Subqu...

Detailed installation steps for MySQL 8.0.11

This article shares the installation steps of MyS...

Mycli is a must-have tool for MySQL command line enthusiasts

mycli MyCLI is a command line interface for MySQL...

js to realize a simple disc clock

This article shares the specific code of js to im...

An example of how to optimize a project after the Vue project is completed

Table of contents 1. Specify different packaging ...

MySQL column to row conversion, method of merging fields (must read)

Data Sheet: Column to row: using max(case when th...

Beginners understand MySQL deadlock problem from source code

After many difficult single-step debugging late a...

Unity connects to MySQL and reads table data implementation code

The table is as follows: Code when Unity reads an...

About Nginx gzip configuration

The principle of nginx to achieve resource compre...

MySQL 8.0.20 Installation Tutorial with Pictures and Text (Windows 64-bit)

1: Download from mysql official website https://d...

Write a publish-subscribe model with JS

Table of contents 1. Scene introduction 2 Code Op...

Detailed installation tutorial of Mysql5.7.19 under Centos7

1. Download Download mysql-5.7.19-linux-glibc2.12...

Docker overlay realizes container intercommunication across hosts

Table of contents 1. Docker configuration 2. Crea...