经过美化的下拉框,当用户的鼠标经过时显示背景颜色,根据自己的需求来自定义。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-Type" content="text/html;charset=gb2312"> <meta name="keywords" content="武鸣人网站,武鸣信息网,武鸣本地网,武鸣信息资源平台,减肥,健身,励志,励志语录,js特效,网页特效,www.wuming.ren"> <meta name="description" content="欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。"> <title>js+css设计美化蓝色下拉菜单效果_武鸣人</title> <style type="text/css"> <!-- body { margin: 0px; padding: 30px 0px 0px 30px; background-color: #CFDFEF; font-size: 12px; } .selectA { width: 92px; height: 17px; padding-left: 10px; padding-top: 5px; background-image: url(/img/20240325_www_wuming_ren_1.gif); overflow: hidden; cursor: pointer; } .selectB { display: none; width: 81px; height: auto; background-image: url(/img/20240325_www_wuming_ren_1.gif); background-position: -102px 0px; border-bottom: 1px solid #4EA0D1; } .selectB .item { width: 71px; height: 17px; background-image: url(/img/20240325_www_wuming_ren_1.gif); background-position: -102px 0px; padding-left: 10px; padding-top: 5px; overflow: hidden; cursor: pointer; } --> </style> <script type="text/javascript"> <!-- //val var items = null; var selectA = null; var selectB = null; var selectAClicked = false; //method function $(s) {//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) return document.getElementById(s); } window.onload = function() { items = [$("itemA"),$("itemB"),$("itemC"),$("itemD"),$("itemE"),$("itemF"),$("itemG"),$("itemH")]; selectA = $("selectA"); selectB = $("selectB"); //init items[0].style.backgroundPosition = "0px -66px"; //selectA event selectA.onmouseover = function() { if(selectAClicked) return; this.style.backgroundPosition = "0px -22px"; } selectA.onmouseout = function() { if(selectAClicked) return; this.style.backgroundPosition = "0px 0px"; } selectA.onclick = function() { if(selectAClicked) { selectAClicked = false; this.style.backgroundPosition = "0px -22px"; selectB.style.display = "none"; return; } selectAClicked = true; this.style.backgroundPosition = "0px -44px"; selectB.style.display = "block"; }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) //selectB event //none //items event function itemMouseOver() { this.style.backgroundPosition = "0px -88px"; } function itemMouseOut() { if(this.innerHTML == selectA.innerHTML) { this.style.backgroundPosition = "0px -66px"; return; } this.style.backgroundPosition = "-102px 0px"; } function itemClick() { for(var i=0,length=items.length;i<length;i++) items[i].style.backgroundPosition = "-102px 0px"; this.style.backgroundPosition = "0px -66px"; selectA.innerHTML = this.innerHTML; selectB.style.display = "none"; selectA.style.backgroundPosition = "0px 0px"; selectAClicked = false; } for(var i=0,length=items.length;i<length;i++) { items[i].onmouseover = itemMouseOver; items[i].onmouseout = itemMouseOut; items[i].onclick = itemClick; } }//武鸣人网站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="selectA" class="selectA">武鸣人号</div> <div id="selectB" class="selectB"> <div id="itemA" class="item">武鸣人一</div> <div id="itemB" class="item">武鸣人二</div> <div id="itemC" class="item">武鸣人三</div> <div id="itemD" class="item">武鸣人四</div> <div id="itemE" class="item">武鸣人五</div> <div id="itemF" class="item">武鸣人六</div> <div id="itemG" class="item">武鸣人七</div> <div id="itemH" class="item">武鸣人八</div> </div> </body> </html>
本文来自武鸣人网站,转载请注明出处