发布网友
共2个回答
懂视网
这篇文章主要介绍了js,jq,css多方面实现简易下拉菜单功能,需要的朋友可以参考下
效果图预览
一 、css实现
html代码部分
css部分
二、js实现
html和js部分(实现方法一)
html和js部分(实现方法二)
css部分
三、JQ实现
html和jq部分
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>JS下拉菜单</title> <link rel="stylesheet" type="text/css" href="css/style.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" /> </head> <body> <ul class="menu" id="menu"> <li> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >首页</a> </li> <li> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >菜单一</a> <ul> <li>内容一</li> <li>内容一</li> <li>内容一</li> </ul> </li> <li> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >菜单二</a> <ul class="show"> <li>内容二</li> <li>内容二</li> <li>内容二</li> </ul> </li> <li> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >菜单三</a> <ul class="hide"> <li>内容三</li> <li>内容三</li> <li>内容三</li> </ul> </li> <li> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >菜单四</a> </li> </ul> <script type="text/javascript" src="../../jq/jquery-1.7.2.min.js"></script> <script type="text/javascript"> $(function(){ $(".menu li").hover(function(){ $(this).children("ul").show(); },function(){ $(this).children("ul").hide(); }); }); </script> </body> </html>
css部分
*{ padding: 0; margin: 0; } a{ text-decoration: none; color: #000; } ul,li{ list-style: none; } .menu{ margin: 50px auto; width: 500px; height: 35px; background-color: #ccc; text-align: center; line-height: 35px; } .menu li{ float: left; width: 20%; position: relative; } .menu li a{ display: block; } .menu li a:hover{ background-color: burlywood; } .menu li ul{ display: none; position: absolute; left: 0; } .menu li ul li{ width: 100%; margin-top: 2px; background-color: darkgray; } .menu li ul li:hover{ cursor: pointer; background-color: chartreuse; }
【相关推荐】
1. 特别推荐:“php程序员工具箱”V0.1版本下载
2. 免费html在线视频教程
3. php.cn原创html5视频教程
热心网友
为了让数据录入的更规范,防止空格或者录入错误,导致后续的数据分析不正确,我们可以使用下拉菜单的方法来进行录入数据,如下所示,可以进行下拉选择
分享3种制作下拉菜单的方法
1、使用快捷键法(ALT+↓)
前面先自己手动的录入一部分数据,如果我们需要输入的数据前面已经输入过的时候,我们可以按ALT+↓键,然后就会自动弹出一个下拉选择,如下所示:
2、使用数据验证方法
我们选中整列数据区域,然后在数据选项卡下,点击数据验证,在弹出的窗口中,选择序列,然后在数据来源里面输入男,女
然后我们在表格里面就可以进行点选了,如下所示
其中数据来源也可以引用单元格的中数据,如下所示:
3、使用开发工具的方法
在开发工具里面,插入一个组合框,在工作表任意位置绘制一个
然后选中组合框,右键,设置控件格式,数据源区域,选择我们需要的下拉数据,链接至任意空白的单元格
然后就可以下拉菜单选择数据了,这个功能经常用来制作一些动态的控制图表
当我们F5单元格输入的公式是:
=INDEX($C$2:$C$5,E1)
随着下拉菜单的数据选择改变,工资信息也会自动的变化。
关于下拉菜单的制作,你学会了么?