js控件模拟select下拉菜单

2个月前 (02-23 17:51)阅读74回复0
大陆
大陆
  • 管理员
  • 发消息
  • 注册排名1
  • 经验值4189
  • 级别管理员
  • 主题837
  • 回复2
楼主

通过js特效实现select下拉菜单特效,这个效果样式很精美,可直接套用或根据自己网站布局来修改样式。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>js控件模拟select下拉菜单_武鸣人</title>
<meta name="keywords" content="武鸣人网站,武鸣信息网,武鸣本地网,武鸣信息资源平台,减肥,健身,励志,励志语录,js特效,网页特效,www.wuming.ren">
<meta name="description" content="欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。">
<style> 
html,body{height:100%;overflow:hidden;}
body,div,form,h2,ul,li{margin:0;padding:0;}
ul{list-style-type:none;}
body{background:#23384e;font:12px/1.5 \5fae\8f6f\96c5\9ed1;}
#search_www_wuming_ren,#search_www_wuming_ren form,#search_www_wuming_ren .box_wuming_ren,#search_www_wuming_ren .select,#search_www_wuming_ren a{background:url(/img/20240223_www_wuming_ren_7.jpg) no-repeat;}
#search_www_wuming_ren,#search_www_wuming_ren .box_wuming_ren,#search_www_wuming_ren form{height:34px;}
#search_www_wuming_ren{position:relative;width:350px;margin:10px auto;}
#search_www_wuming_ren .box_wuming_ren{background-position:right 0;}
#search_www_wuming_ren form{background-repeat:repeat-x;background-position:0 -34px;margin:0 20px 0 40px;}
#search_www_wuming_ren .select{float:left;color:#fff;width:190px;height:22px;cursor:pointer;margin-top:4px;line-height:22px;padding-left:10px;background-position:0 -68px;}
#search_www_wuming_ren a{float:left;width:80px;height:24px;color:#333;letter-spacing:4px;line-height:22px;text-align:center;text-decoration:none;background-position:0 -90px;margin:4px 0 0 10px;}
#search_www_wuming_ren a:hover{color:#f60;background-position:-80px -90px;}
#search_www_wuming_ren .sub{position:absolute;top:26px;left:40px;color:#fff;width:198px;background:#2b2b2b;border:1px solid #fff;display:none;}
#search_www_wuming_ren .sub li{height:25px;line-height:24px;cursor:pointer;padding-left:10px;margin-bottom:-1px;border-bottom:1px dotted #fff;}
#search_www_wuming_ren .sub li.hover{background:#8b8b8b;}
</style>
<script type="text/javascript"> 
window.onload = function ()
{//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
var oSelect = document.getElementsByTagName("span")[0];
var oSub = document.getElementsByTagName("ul")[0];
var aLi = oSub.getElementsByTagName("li");
var i = 0;
oSelect.onclick = function (event)
{
var style = oSub.style;
style.display = style.display == "block" ? "none" : "block";
//阻止事件冒泡
(event || window.event).cancelBubble = true
};
for (i = 0; i < aLi.length; i++)
{
//鼠标划过
aLi[i].onmouseover = function ()
{
this.className = "hover"
};
//鼠标离开
aLi[i].onmouseout = function ()
{
this.className = "";
};
//鼠标点击
aLi[i].onclick = function ()
{
oSelect.innerHTML = this.innerHTML
}
}
document.onclick = function ()
{
oSub.style.display = "none";
};
};//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
</script>
</head>
<body>
<a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr>
<!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。-->
<script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script>
<script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script>
<div id="search_www_wuming_ren">
    <div class="box_wuming_ren">
        <form>
            <span class="select">请选择游戏名称</span>        
            <a href="javascript:;">搜索</a>
        </form>
    </div>
    <ul class="sub">
        <li>地下城与勇士</li>
        <li>魔兽世界(国服)</li>
        <li>魔兽世界(台服)</li>
        <li>热血江湖</li>
        <li>神鬼传奇</li>
        <li>大话西游II</li>
        <li>QQ幻想世界</li>
    </ul>
</div>
</body>
</html>


0
0
收藏0
回帖

js控件模拟select下拉菜单 期待您的回复!

取消
载入表情清单……
载入颜色清单……
插入网络图片

取消确定

图片上传中
编辑器信息
提示信息