Home Web Front-end HTML Tutorial The simplest menu code_html/css_WEB-ITnose

The simplest menu code_html/css_WEB-ITnose

Jun 24, 2016 am 11:42 AM

 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>最简单的菜单</title> 6 <style> 7     *{margin: 0;padding: 0;} 8     .moyu ul a{font-family: '微软雅黑';font-size: 14px;color: #333;text-decoration: none;} 9     .moyu ul a:hover{color: #000;text-decoration: none;}10     .moyu ul li{width: 100px;height: 35px;line-height: 35px;text-align: center;position: relative;}11     .moyu ul li:hover{background: #c1c1c1;}12     .moyu ul{width: 100px;height: auto;position: absolute;background: #DADADA;list-style: none;}13 14     .moyu ul.nav2{left: 99px;top: 0;display: none;}15     .moyu ul.nav3{left: 99px;top: 0;display: none;}16     .moyu .nav1 .li1:hover ul.nav2{display: block;background: #c1c1c1;}17     .moyu .nav2 .li2:hover ul.nav3{display: block;background: #c1c1c1;}18     .moyu .nav2 ,.moyu .nav2 li:hover {background:#ccc;}19 </style>20 </head>21 <body>22 <!--代码部分begin-->23 <div class="moyu">24 <ul class="nav1">25     <li class="li1"><a href="#">一级导航</a>26         <ul class="nav2">27             <li class="li2"><a href="#">二级导航</a></li>28             <li class="li2"><a href="#">二级导航</a>29                 <ul class="nav3">30                     <li class="li3"><a href="#">三级导航</a></li>31                     <li class="li3"><a href="#">三级导航</a></li>32                     <li class="li3"><a href="#">三级导航</a></li>33                     <li class="li3"><a href="#">三级导航</a></li>34                 </ul>35             </li>36             <li class="li2"><a href="#">二级导航</a></li>37             <li class="li2"><a href="#">二级导航</a></li>38         </ul>39     </li>40     <li class="li1"><a href="#">一级导航</a></li>41     <li class="li1"><a href="#">一级导航</a></li>42     <li class="li1"><a href="#">一级导航</a></li>43     <li class="li1"><a href="#">一级导航</a></li>44     <li class="li1"><a href="#">一级导航</a></li>45 </ul>46 </div>47 <!--代码部分end-->48 </body>49 </html>
Copy after login


The above code can easily understand the concept of menu.

The menu is the opening (display:block;) and closing (display:hidden;) of the small box in the box

The idea is the same, but the implementation method is different. It can be written in pure CSS , JavaScript and jQuery can also be used. Or more complex plug-ins bootstrap, jQuery UI, etc.

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 Article Tags

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)

Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update? Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update? Mar 04, 2025 pm 12:32 PM

Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?

How do I use HTML5 form validation attributes to validate user input? How do I use HTML5 form validation attributes to validate user input? Mar 17, 2025 pm 12:27 PM

How do I use HTML5 form validation attributes to validate user input?

What is the purpose of the <iframe> tag? What are the security considerations when using it? What is the purpose of the <iframe> tag? What are the security considerations when using it? Mar 20, 2025 pm 06:05 PM

What is the purpose of the <iframe> tag? What are the security considerations when using it?

How to efficiently add stroke effects to PNG images on web pages? How to efficiently add stroke effects to PNG images on web pages? Mar 04, 2025 pm 02:39 PM

How to efficiently add stroke effects to PNG images on web pages?

What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

What is the purpose of the <meter> element?

What are the best practices for cross-browser compatibility in HTML5? What are the best practices for cross-browser compatibility in HTML5? Mar 17, 2025 pm 12:20 PM

What are the best practices for cross-browser compatibility in HTML5?

What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

What is the purpose of the <datalist> element?

What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

What is the purpose of the <progress> element?

See all articles