今天给大家带来的是无论什么网站都有可能用到的万能的符合WEB标准的CSS下拉导航菜单布局及css下拉菜单模板!快点保存一下吧! <ul id="nav"> <li><a href="http://www.divcss5.com/">div+css</a> <ul> <li><a href="http://www.divcss5.com/">CSS</a></li> <li><a href="#">产品一</a></li> <li><a href="#">产品一</a></li> <li><a href="#">产品一</a></li> <li><a href="#">产品一</a></li> <li><a href="#">产品一</a></li> </ul> </li> <li><a href="http://www.divcss5.com/rumen/">css入门</a> <ul> <li><a href="#">入门一</a></li> <li><a href="#">入门二</a></li> <li><a href="#">入门二</a></li> <li><a href="#">入门二入门二</a></li> <li><a href="#">入门二入门二入门二</a></li> <li><a href="#">入门二</a></li> </ul> </li> <li><a href="http://www.divcss5.com/html/">HTML基础</a> <ul> <li><a href="#">基础三</a></li> <li><a href="#">基础</a></li> <li><a href="#">基础三案例三</a></li> <li><a href="#">基础三案例三案例三</a></li> </ul> </li> <li><a href="http://www.divcss5.com/jiqiao/">DIV+CSS技巧</a> <ul> <li><a href="#">技巧四</a></li> <li><a href="#">技巧四</a></li> <li><a href="#">技巧四</a></li> <li><a href="#">技巧四111</a></li> </ul> </li> <li><a href="http://www.divcss5.com/template/">DIV+CSS模板</a> <ul> <li><a href="http://www.divcss5.com/template/">CSS模板</a></li> <li><a href="#">模板</a></li> <li><a href="#">模板</a></li> <li><a href="#">模板模板</a></li> <li><a href="#">模板模板模板</a></li> <li><a href="#">模板模板</a></li> <li><a href="#">模板模板</a></li> <li><a href="#">模板模板模板模板</a></li> </ul> </li> <li><a href="http://www.divcss5.com/shouce/">CSS手册</a> <ul> <li><a href="http://www.divcss5.com/shouce/">DIV+CSS手册</a></li> <li><a href="#">手册</a></li> <li><a href="#">手册</a></li> <li><a href="#">手册</a></li> <li><a href="#">手册</a></li> <li><a href="#">手册手册</a></li> <li><a href="#">手册手册手册</a></li> </ul> </li> </ul>
CSS 代码及JS代码:
<style type="text/css"> /* www.divcss5.com CSS下拉菜单实例 */ *{margin:0;padding:0;border:0} body{ font-family: arial, 宋体, serif; font-size:12px} #nav{line-height: 24px; list-style-type: none; background:#666} #nav a{display: block; width: 80px; text-align:center} #nav a:link {color:#666; text-decoration:none} #nav a:visited {color:#666;text-decoration:none} #nav a:hover {color:#FFF;text-decoration:none;font-weight:bold} #nav li{float: left; width: 80px; background:#CCC} #nav li a:hover{ background:#999} #nav li ul{line-height: 27px; list-style-type: none;text-align:left;left: -999em; width: 180px; position: absolute} #nav li ul li{float: left; width: 180px;background:#EFEFEF} #nav li ul a{display: block; width: 156px;text-align:left;padding-left:24px; overflow:hidden} #nav li ul a:link {color:#666; text-decoration:none} #nav li ul a:visited {color:#666;text-decoration:none} #nav li ul a:hover {color:#F3F3F3;text-decoration:none;font-weight:normal;background:#C00} #nav li:hover ul{left: auto} #nav li.sfhover ul{left: auto} #content{clear: left} </style> <script type=text/javascript> function menuFix(){ var sfEls = document.getElementById("nav").getElementsByTagName("li"); for (var i=0; i<sfEls.length; i++){ sfEls[i].onmouseover=function(){ this.className+=(this.className.length>0? " ": "") + "sfhover"; } sfEls[i].onMouseDown=function(){ this.className+=(this.className.length>0? " ": "") + "sfhover"; } sfEls[i].onMouseUp=function(){ this.className+=(this.className.length>0? " ": "") + "sfhover"; } sfEls[i].onmouseout=function(){ thisthis.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), ""); } } } window.onload=menuFix; </script>
以上为DIV+CSS模板中的纯CSS下拉菜单布局代码及说明。
有需要的朋友快快保存一下吧。
相关阅读:
The above is the detailed content of Use DIV and CSS to make drop-down menu. For more information, please follow other related articles on the PHP Chinese website!

The fact that anchor positioning eschews HTML source order is so CSS-y because it's another separation of concerns between content and presentation.

Article discusses CSS margin property, specifically "margin: 40px 100px 120px 80px", its application, and effects on webpage layout.

The article discusses CSS border properties, focusing on customization, best practices, and responsiveness. Main argument: border-radius is most effective for responsive designs.

The article discusses CSS background properties, their uses in enhancing website design, and common mistakes to avoid. Key focus is on responsive design using background-size.

Article discusses CSS HSL colors, their use in web design, and advantages over RGB. Main focus is on enhancing design and accessibility through intuitive color manipulation.

The article discusses the use of comments in CSS, detailing single-line and multi-line comment syntaxes. It argues that comments enhance code readability, maintainability, and collaboration, but may impact website performance if not managed properly.

The article discusses CSS Selectors, their types, and usage for styling HTML elements. It compares ID and class selectors and addresses performance issues with complex selectors.

The article discusses CSS priority, focusing on inline styles having the highest specificity. It explains specificity levels, overriding methods, and debugging tools for managing CSS conflicts.


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

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Chinese version
Chinese version, very easy to use

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
