Use DIV and CSS to make drop-down menu
今天给大家带来的是无论什么网站都有可能用到的万能的符合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!

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

Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-
