search
HomeWeb Front-endHTML Tutorial'Mastering CSS' An example of a drop-down menu_html/css_WEB-ITnose

This example is for a drop-down menu. I made a few changes. The principle is indeed very simple, but the author's code hierarchy is very clear and worth learning. Another point is the author's colors during the interaction process. Changes, even precise changes between border lines, although it is basically invisible from the perspective of an onlooker, this kind of meticulous thinking and design is worth learning and thinking about, the so-called subtle prescription Whether the skills are mature or not, I think this makes sense! Without further ado, here’s the code:

  1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  2 <html xmlns="http://www.w3.org/1999/xhtml">  3 <head>  4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  5 <title>滑动门航条</title>  6 <style type="text/css">  7     *{margin:30 0;padding: 0;list-style: none;}  8     ul.main,ul.main ul{  9         float:left; 10         border:1px solid #486B02; 11         background-color:#8BD400; 12         } 13     ul.main li{ 14         float:left; 15         width:120px; 16         height:30px; 17         line-height:30px; 18         text-align:center; 19         } 20     ul.main li ul{ 21         width:120px; 22         position:absolute;left:-999em; 23         } 24     ul.main li:hover ul{ 25         left:auto;//AUTO时它会自动悬浮在下方 26         } 27     ul.main a{ 28         display:block; 29         color:#2B3F00; 30         border-left:1px solid #E4FFD3; 31         border-right:1px solid #486B02; 32         text-decoration:none; 33         } 34     ul.main li li a{ 35         border-top:1px solid #E4FFD3; 36         border-bottom:1px solid #486B02; 37         border-left:0; 38         border-right:0; 39         } 40     ul.main li:last-child a{ 41         border-bottom:0; 42         border-right:0; 43         } 44     ul a:hover,ul a:focus{ 45         color:#E4FFD3; 46         background-color:#6DA203; 47         } 48 </style> 49 </head> 50 <body> 51     <ul class="main"> 52         <li><a href="#" class="selected">首页</a></li> 53         <li><a href="#">教学</a> 54             <ul> 55                 <li><a href="#">本科生教学</a></li> 56                 <li><a href="#">研究生教学</a></li> 57                 <li><a href="#">中小学教学</a></li> 58                 <li><a href="#">远程教育</a></li> 59             </ul> 60         </li> 61         <li><a href="#">科研</a> 62             <ul> 63                 <li><a href="#">论文发表</a></li> 64                 <li><a href="#">实验室</a></li> 65                 <li><a href="#">产品展示</a></li> 66             </ul> 67         </li> 68         <li><a href="#">后勤</a> 69             <ul> 70                 <li><a href="#">规章制度</a></li> 71                 <li><a href="#">资料下载</a></li> 72                 <li><a href="#">设施开放时间</a></li> 73                 <li><a href="#">通知公告</a></li> 74             </ul> 75         </li> 76         <li><a href="#">安全保障</a> 77                <ul> 78                 <li><a href="#">保卫处</a></li> 79                 <li><a href="#">网上报警</a></li> 80                 <li><a href="#">案件公示</a></li> 81             </ul> 82         </li> 83         <li><a href="#">关于我们</a> 84                <ul> 85                 <li><a href="#">学校简介</a></li> 86                 <li><a href="#">校歌校徽</a></li> 87                 <li><a href="#">校内导航</a></li> 88                 <li><a href="#">学校历史</a></li> 89                 <li><a href="#">学校荣誉</a></li> 90             </ul> 91         </li> 92         <li><a href="#">联系我们</a> 93             <ul> 94                 <li><a href="#">写邮件</a></li> 95                 <li><a href="#">联系电话</a></li> 96                 <li><a href="#">校区地址</a></li> 97             </ul> 98         </li> 99     </ul>100 </body>101 </html>

Statement
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
What is the root tag in an HTML document?What is the root tag in an HTML document?Apr 29, 2025 am 12:10 AM

TheroottaginanHTMLdocumentis.Itservesasthetop-levelelementthatencapsulatesallothercontent,ensuringproperdocumentstructureandbrowserparsing.

Are the HTML tags and elements the same thing?Are the HTML tags and elements the same thing?Apr 28, 2025 pm 05:44 PM

The article explains that HTML tags are syntax markers used to define elements, while elements are complete units including tags and content. They work together to structure webpages.Character count: 159

What is the significance of <head> and <body> tag in HTML?What is the significance of <head> and <body> tag in HTML?Apr 28, 2025 pm 05:43 PM

The article discusses the roles of <head> and <body> tags in HTML, their impact on user experience, and SEO implications. Proper structuring enhances website functionality and search engine optimization.

What is the difference between <strong>, <b> tags and <em>, <i> tags?What is the difference between <strong>, <b> tags and <em>, <i> tags?Apr 28, 2025 pm 05:42 PM

The article discusses the differences between HTML tags , , , and , focusing on their semantic vs. presentational uses and their impact on SEO and accessibility.

Please explain how to indicate the character set being used by a document in HTML?Please explain how to indicate the character set being used by a document in HTML?Apr 28, 2025 pm 05:41 PM

Article discusses specifying character encoding in HTML, focusing on UTF-8. Main issue: ensuring correct display of text, preventing garbled characters, and enhancing SEO and accessibility.

What are the various formatting tags in HTML?What are the various formatting tags in HTML?Apr 28, 2025 pm 05:39 PM

The article discusses various HTML formatting tags used for structuring and styling web content, emphasizing their effects on text appearance and the importance of semantic tags for accessibility and SEO.

What is the difference between the 'id' attribute and the 'class' attribute of HTML elements?What is the difference between the 'id' attribute and the 'class' attribute of HTML elements?Apr 28, 2025 pm 05:39 PM

The article discusses the differences between HTML's 'id' and 'class' attributes, focusing on their uniqueness, purpose, CSS syntax, and specificity. It explains how their use impacts webpage styling and functionality, and provides best practices for

What is the 'class' attribute in HTML?What is the 'class' attribute in HTML?Apr 28, 2025 pm 05:37 PM

The article explains the HTML 'class' attribute's role in grouping elements for styling and JavaScript manipulation, contrasting it with the unique 'id' attribute.

See all articles

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

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),