这一技客
看到PHP技术背后的趋势
首页
实用工具网址
导航
相册
留言
吼吼箱
电脑主题网
白看网
登入
下拉列表-select样式css处理
Feb 14 17:43 出处:本站原创
大
|
中
|
小
找了半天才找到这个代码比较少的样式处理下拉列表的,有兴趣的可以看一看,我网站侧边那个搜索列表就是用的第三种改完之后效果真的不错,第一种效果为:
第一种列表样式:
<!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>css处理下拉列表-这一技客:www.geekso.com</title> <style> .IN { BORDER-RIGHT: #afaeae 1px solid; BORDER-TOP: #afaeae 1px solid; FONT-SIZE: 10pt; BORDER-LEFT: #afaeae 1px solid; COLOR: #7b7b7b; BORDER-BOTTOM: #afaeae 1px solid; FONT-FAMILY: "verdana" } .selectBoxSelectedArea { PADDING-LEFT: 3px; FONT-SIZE: 12px; COLOR: #000000; LINE-HEIGHT: 17px; PADDING-TOP: 1px; BACKGROUND-COLOR: #ffffff } .selectBoxSelectedAreaFocus { PADDING-LEFT: 3px; FONT-SIZE: 12px; COLOR: #333333; LINE-HEIGHT: 17px; PADDING-TOP: 1px; BACKGROUND-COLOR: #ffffff } .selectBoxOption { PADDING-LEFT: 3px; FONT-SIZE: 12px; COLOR: #000000; LINE-HEIGHT: 17px; PADDING-TOP: 2px; BACKGROUND-COLOR: #ffffff } .selectBoxOptionOver { PADDING-LEFT: 3px; FONT-SIZE: 12px; COLOR: #333333; LINE-HEIGHT: 17px; PADDING-TOP: 2px; BACKGROUND-COLOR: #ffffff } .selectBoxOptionInnerLayer { BORDER-RIGHT: #b4b4b4 1px solid; BORDER-TOP: #b4b4b4 1px solid; SCROLLBAR-FACE-COLOR: #ffffff; SCROLLBAR-HIGHLIGHT-COLOR: #b4b4b4; OVERFLOW: auto; BORDER-LEFT: #b4b4b4 1px solid; SCROLLBAR-SHADOW-COLOR: #b4b4b4; SCROLLBAR-3DLIGHT-COLOR: #ffffff; SCROLLBAR-ARROW-COLOR: #838383; SCROLLBAR-TRACK-COLOR: #eaeaea; BORDER-BOTTOM: #b4b4b4 1px solid; SCROLLBAR-DARKSHADOW-COLOR: #ffffff; BACKGROUND-COLOR: #ffffff } </style> </head> <body > <SCRIPT LANGUAGE="JavaScript"> var nowOpenedSelectBox = ""; var mousePosition = ""; function selectThisValue(thisId,thisIndex,thisValue,thisString) { var objId = thisId; var nowIndex = thisIndex; var valueString = thisString; var sourceObj = document.getElementById(objId); var nowSelectedValue = document.getElementById(objId+"SelectBoxOptionValue"+nowIndex).value; hideOptionLayer(objId); if (sourceObj) sourceObj.value = nowSelectedValue; settingValue(objId,valueString); selectBoxFocus(objId); if (sourceObj.onchange) sourceObj.onchange(); } function settingValue(thisId,thisString) { var objId = thisId; var valueString = thisString; var selectedArea = document.getElementById(objId+"selectBoxSelectedValue"); if (selectedArea) selectedArea.innerText = valueString; } function viewOptionLayer(thisId) { var objId = thisId; var optionLayer = document.getElementById(objId+"selectBoxOptionLayer"); if (optionLayer) optionLayer.style.display = ""; nowOpenedSelectBox = objId; setMousePosition("inBox"); } function hideOptionLayer(thisId) { var objId = thisId; var optionLayer = document.getElementById(objId+"selectBoxOptionLayer"); if (optionLayer) optionLayer.style.display = "none"; } function setMousePosition(thisValue) { var positionValue = thisValue; mousePosition = positionValue; } function clickMouse() { if (mousePosition == "out") hideOptionLayer(nowOpenedSelectBox); } function selectBoxFocus(thisId) { var objId = thisId; var obj = document.getElementById(objId + "selectBoxSelectedValue"); obj.className = "selectBoxSelectedAreaFocus"; obj.focus(); } function selectBoxBlur(thisId) { var objId = thisId; var obj = document.getElementById(objId + "selectBoxSelectedValue"); obj.className = "selectBoxSelectedArea"; } function makeSelectBox(thisId) { var downArrowSrc = "http://www.geekso.com/attachment/3j.jpg"; //三角 var downArrowSrcWidth = 16; //宽 var optionHeight = 18; // 高 var optionMaxNum = 7; // var optionInnerLayerHeight = ""; var objId = thisId; var obj = document.getElementById(objId); var selectBoxWidth = parseInt(obj.style.width); var selectBoxHeight = parseInt(obj.style.height); if (obj.options.length > optionMaxNum) optionInnerLayerHeight = "height:"+ (optionHeight * optionMaxNum) + "px"; newSelect = "<table id='" + objId + "selectBoxOptionLayer' cellpadding='0' cellspacing='0' border='0' style='position:absolute;z-index:100;display:none;' onMouseOver=\"viewOptionLayer('"+ objId + "')\" onMouseOut=\"setMousePosition('out')\">"; newSelect += " <tr>"; newSelect += " <td height='" + selectBoxHeight + "' style='cursor:hand;' onClick=\"hideOptionLayer('"+ objId + "')\"></td>"; newSelect += " </tr>"; newSelect += " <tr>"; newSelect += " <td height='1'></td>"; newSelect += " </tr>"; newSelect += " <tr>"; newSelect += " <td bgcolor='#D3D3D3'>"; newSelect += " <div class='selectBoxOptionInnerLayer' style='width:" + (selectBoxWidth-1) + "px;" + optionInnerLayerHeight + "'>"; newSelect += " <table cellpadding='0' cellspacing='0' border='0' width='100%' style='table-layout:fixed;word-break:break-all;'>"; for (var i=0 ; i < obj.options.length ; i++) { var nowValue = obj.options[i].value; var nowText = obj.options[i].text; newSelect += " <tr>"; newSelect += " <td onMouseOver=this.style.backgroundColor='#FFBA00';return true; onMouseOut=this.style.backgroundColor='FFFFFF';return true; bgcolor=#FFFFFF height='" + optionHeight + "' class='selectBoxOption' onMouseOver=\"this.className='selectBoxOptionOver'\" onMouseOut=\"this.className='selectBoxOption'\" onClick=\"selectThisValue('"+ objId + "'," + i + ",'" + nowValue + "','" + nowText + "')\" style='cursor:hand;' >" + nowText + "</td>"; newSelect += " <input type='hidden' id='"+ objId + "SelectBoxOptionValue" + i + "' value='" + nowValue + "'>"; newSelect += " </tr>"; } newSelect += " </table>"; newSelect += " </div>"; newSelect += " </td>"; newSelect += " </tr>"; newSelect += "</table>"; newSelect += "<table cellpadding='0' cellspacing='1' border='0' bgcolor='#B4B4B4' onClick=\"viewOptionLayer('"+ objId + "')\" style='cursor:hand;'>"; newSelect += " <tr>"; newSelect += " <td style='padding-left:1px' bgcolor='#FFFFFF'>"; newSelect += " <table cellpadding='0' cellspacing='0' border='0'>"; newSelect += " <tr>"; newSelect += " <td><div id='" + objId + "selectBoxSelectedValue' class='selectBoxSelectedArea' style='width:" + (selectBoxWidth - downArrowSrcWidth - 4) + "px;height:" + (selectBoxHeight - 2) + "px;overflow:hidden;' onBlur=\"selectBoxBlur('" + objId + "')\" ></div></td>"; newSelect += " <td><img src='" + downArrowSrc + "' width='" + downArrowSrcWidth + "' border='0'></td>"; newSelect += " </tr>"; newSelect += " </table>"; newSelect += " </td>"; newSelect += " </tr>"; newSelect += "</table>"; document.write(newSelect); var haveSelectedValue = false; for (var i=0 ; i < obj.options.length ; i++) { if (obj.options[i].selected == true) { haveSelectedValue = true; settingValue(objId,obj.options[i].text); } } if (!haveSelectedValue) settingValue(objId,obj.options[0].text); } document.onmousedown = clickMouse; </SCRIPT> <Select class=in id=selectTest style="DISPLAY: none; BACKGROUND: #ffffff; WIDTH: 130px; HEIGHT: 19px" name=search> <OPTION value="" selected>www.geekso.com</OPTION> <OPTION value=name>geekso.com</OPTION> <OPTION value=title>这一技客</OPTION> </Select> <SCRIPT>makeSelectBox("selectTest");</SCRIPT> </body> </html>
提示:您可以先修改部分代码再运行
第二种:美化列表
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> simulate combox control - http://www.never-online.net </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> <style> body, input { font-family: verdana; font-size: 9pt; } h1 { font-family: tahoma; font-size: 22pt; text-align: left; } pre { font-size: 9pt; font-family: verdana; border: 1px solid #006600; width: 400px; padding: 10px; background: #ffffff; color: #006600; } .CtlSelect { border: 1px solid #006600; font-family: verdana; height: 20px; color: #006600; background: #ffffff; /*background:url({E5066804-650D-4757-9BA4-A92DB8817A18}0.jpg);*/ } .selected { background: #006600; color: #ffffff; height: 20px; } .unselected { height: 20px; color: #006600; line-height: 120%; border-bottom: 1px solid #006600; } .CtlSelect1 { border: 1px solid #003399; font-family: verdana; height: 20px; color: #003399; background: #ffffff; /*background:url({E5066804-650D-4757-9BA4-A92DB8817A18}0.jpg);*/ } .selected1 { background: #003399; color: #ffffff; height: 20px; } .unselected1 { height: 20px; color: #003399; line-height: 120%; border-bottom: 1px solid #003399; } .CtlSelect2 { border: 1px solid #990000; font-family: verdana; height: 20px; color: #990000; background: #ffffff; /*background:url({E5066804-650D-4757-9BA4-A92DB8817A18}0.jpg);*/ } .selected2 { background: #990000; color: #ffffff; height: 20px; } .unselected2 { height: 20px; color: #990000; line-height: 120%; border-bottom: 1px solid #990000; } .copyright { margin-top: 10px; font-size: 9pt; text-align: center; color: #333; font-weight: bold; } </style> </HEAD> <BODY> <SCRIPT LANGUAGE="JavaScript"> <!-- //------------------------------------------------------------- // @ Module: simulate select control, IE only. // @ Debug in: IE 6.0 // @ Script by: blueDestiny, never-online // @ Updated: 2006-3-22 // @ Version: 1.0 apha // @ Email: blueDestiny [at] 126.com // @ Website: http://www.never-online.net // @ Please Hold this item please. // // API // @ class: simulateSelect() // // @ object.style(ctlStyle[,selStyle][,unselStyle]) // ctlStyle: main control combox css class name // selStyle: when mouseover or option focus css class name // unselStyle: options blur's css class name // // @ object.width=(widthPX) // widthPX must be a digit number. // // @ object.height=(heightPX) // heightPX must be a digit number. // // @ object.getValue(ctlSelID) // ctlSelID is the unique select control ID // // -------------- for the next Version ---------- // @ object.readOnly = (blnReadOnly) // blnReadOnly must be a boolean type or a number type. // @ object.addEvent(w, h) // w: fire handler's event. // h: handler function. //------------------------------------------------------------- function $(objID) { return document.getElementById(objID); }; function Offset(e) { var t = e.offsetTop; var l = e.offsetLeft; var w = e.offsetWidth; var h = e.offsetHeight-2; while(e=e.offsetParent) { t+=e.offsetTop; l+=e.offsetLeft; } return { top : t, left : l, width : w, height : h } } //----------------------------------------------- function simulateSelect() { with(this) { this.IDs = []; this.name = this; // property for beta Version // can editable combox this.readonly = true; this.height = 20; this.width = null; this.ctlStyle = "CtlSelect"; this.selStyle = "selected"; this.unselStyle = "unselected"; this.elementPrefix = "e__"; this.inputPrefix = "i__"; this.containerPrefix = "c__"; this.buttonPrefix = "b__"; return this; }}; simulateSelect.prototype.init = function(ctlSelIDs) { with(this) { eval(name).append(ctlSelIDs); eval(name).simulates(); }}; simulateSelect.prototype.style = function() { with(this) { ctlStyle = arguments[0]; selStyle = arguments[1]; unselStyle = arguments[2]; }}; //----------------------------------------------- simulateSelect.prototype.append = function(ctlSelIDs) { with(this) { if( ctlSelIDs.indexOf(",")>0 ) { var arrCtlSel = ctlSelIDs.split(","); for(var i=0; i<arrCtlSel.length; i++) { eval(name).IDs.push(arrCtlSel[i]); } } else { eval(name).IDs.push(ctlSelIDs); } }}; simulateSelect.prototype.checkupOnMouseDown = function(e) { with(this) { // here compatible mf. var el = e ? e.srcElement : e.target; if( el.id.indexOf(elementPrefix)>-1 || el.id.indexOf(inputPrefix)>-1 || el.id.indexOf(containerPrefix)>-1 || el.id.indexOf(buttonPrefix)>-1 ) { return; } else { for(var i=0; i<eval(name).IDs.length; i++) if( $(containerPrefix + IDs[i]) ) $(containerPrefix + eval(name).IDs[i]).style.display = "none"; } }}; simulateSelect.prototype.simulates = function() { with(this) { for(var i=0; i<IDs.length; i++) eval(name).simulate(IDs[i]); }}; simulateSelect.prototype.simulate = function(ctlSelID) { with (this) { var input; var button; var object; var offset; object = $(ctlSelID); offset = Offset(object); input = document.createElement("INPUT"); button = document.createElement("BUTTON"); button.setAttribute("id", buttonPrefix + ctlSelID); //button.value = "⊿"; button.value = "6"; button.style.fontFamily = "Webdings, Marlett"; button.style.background = ""; button.onclick = input.onclick = function() { this.blur(); eval(name).expand(ctlSelID, offset); } input.onselectstart = function() { eval(name).expand(ctlSelID, offset); event.returnValue = false; }; input.setAttribute("id", inputPrefix + ctlSelID); input.title = button.title = "click expand options"; input.style.cursor = button.style.cursor = "default"; input.className = button.className = ctlStyle; input.style.width = (width>0 ? width : object.offsetWidth); height ? input.style.height=button.style.height=height : ""; input.value = object[0].text; if( readonly==true ) input.readOnly=true; // this method is only IE. object.insertAdjacentElement("afterEnd",button); object.insertAdjacentElement("afterEnd",input); object.style.display = 'none'; }}; simulateSelect.prototype.expand = function(ctlSelID, offset) { with(this) { var div, btn_off; var object = $(ctlSelID); if( !$(containerPrefix + ctlSelID) ) { div = document.createElement("DIV"); div.style.position = "absolute"; div.style.display = "block"; div.setAttribute("id", containerPrefix + ctlSelID); div.className = ctlStyle; div.style.left = offset.left; div.style.top = offset.top + offset.height; div.style.width = (width ? width : offset.width) + 20; div.style.height = offset.height; document.body.appendChild(div); for(var i=0; i<object.length; i++) { div = document.createElement("DIV"); div.setAttribute("id", div.id = elementPrefix + ctlSelID + i); div.style.cursor = "default"; if( object[i].text==$(inputPrefix + ctlSelID).value ) div.className = selStyle; else div.className = unselStyle; div.innerText = div.title = object[i].text; div.style.height = height; div.setAttribute("value", object[i].value); div.onmouseover = function() { for(var j=0; j<$(containerPrefix + ctlSelID).childNodes.length; j++) { if($(containerPrefix + ctlSelID).childNodes[j]==this) $(containerPrefix + ctlSelID).childNodes[j].className = selStyle; else $(containerPrefix + ctlSelID).childNodes[j].className = unselStyle; } }; div.onclick = function() { $(inputPrefix + ctlSelID).value = this.innerText; $(containerPrefix + ctlSelID).style.display = "none"; }; $(containerPrefix + ctlSelID).appendChild(div); } return; } if( $(containerPrefix + ctlSelID).style.display=="none" ) { for(var i=0; i<object.length; i++) { if( object[i].text==$(inputPrefix + ctlSelID).value ) $(elementPrefix + ctlSelID + i).className = selStyle; else $(elementPrefix + ctlSelID + i).className = unselStyle; } $(containerPrefix + ctlSelID).style.display="block"; return; } if( $(containerPrefix + ctlSelID).style.display=="block" ) { $(containerPrefix + ctlSelID).style.display="none"; return; } }}; simulateSelect.prototype.getValue = function(ctlSelID) { with(this) { if( $(inputPrefix + ctlSelID) ) return $(inputPrefix + ctlSelID).value; else return null; }}; simulateSelect.prototype.addEvent = function(w, h) { with(this) { }}; //----------------------------------------------- //window.onerror = Function("return true;"); // IE only. document.attachEvent("onmousedown", function() { a.checkupOnMouseDown(event); b.checkupOnMouseDown(event); c.checkupOnMouseDown(event) } ); //--> </SCRIPT> <h1> simulate combox control </h1> <h4> demonstrate </h4> <p> <select id="s0"> <option value="- please select your options -"> - please select your options -</option> <option value="1">option1</option> <option value="2">option2</option> <option value="3">option3</option> <option value="4">option4</option> <option value="5">option5</option> </select> </p> <p> <select id="s1"> <option value="- please select your options -"> - please select your options -</option> <option value="1">1option1</option> <option value="2">1option2</option> <option value="3">1option3</option> <option value="4">1option4</option> <option value="5">1option5</option> </select> </p> <p> <select id="s2"> <option value="- please select your options -"> - please select your options -</option> <option value="1">2option1</option> <option value="2">2option2</option> <option value="3">2option3</option> <option value="4">2option4</option> <option value="5">2option5</option> </select> </p> <p> <select id="s3"> <option value="- please select your options -"> - please select your options -</option> <option value="1">3option1</option> <option value="2">3option2</option> <option value="3">3option3</option> <option value="4">3option4</option> <option value="5">3option5</option> </select> </p> <button onclick="alert(a.getValue('s1') + '\n\n' + b.getValue('s2'))" class="CtlSelect"> Get value </button> <SCRIPT LANGUAGE="JavaScript"> <!-- var a = new simulateSelect(); a.style("CtlSelect", "selected", "unselected"); a.init("s1"); var b = new simulateSelect(); b.style("CtlSelect1", "selected1", "unselected1"); b.width = 300; b.init("s2"); var c = new simulateSelect(); c.style("CtlSelect2", "selected2", "unselected2"); c.width = 320; c.init("s3"); //--> </SCRIPT> <div class="copyright"> http://www.geekso.com </div> </BODY> </HTML>
提示:您可以先修改部分代码再运行
第三种下拉列表
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd"> <HTML xmlns="http://www.w3.org/1999/xhtml"> <HEAD> <TITLE>Select Demo</TITLE> <META http-equiv=Content-Type content="text/html; charset=utf-8"> <STYLE type=text/css> BODY { BACKGROUND: #cfdfef; FONT: 12px/150% "Lucida Grande", Arial, Verdana, Helvetica, sans-serif } #uboxstyle .select_box { WIDTH: 250px; HEIGHT: 24px } #uboxstyle DIV.tag_select { PADDING-RIGHT: 10px; DISPLAY: block; PADDING-LEFT: 10px; BACKGROUND: url(http://www.geekso.com/attachment/ubox-select.gif) no-repeat 0px 0px; PADDING-BOTTOM: 0px; WIDTH: 230px; COLOR: #79a2bd; LINE-HEIGHT: 24px; PADDING-TOP: 0px; HEIGHT: 24px } #uboxstyle DIV.tag_select_hover { PADDING-RIGHT: 10px; DISPLAY: block; PADDING-LEFT: 10px; BACKGROUND: url(http://www.geekso.com/attachment/ubox-select.gif) no-repeat 0px -24px; PADDING-BOTTOM: 0px; WIDTH: 230px; COLOR: #79a2bd; LINE-HEIGHT: 24px; PADDING-TOP: 0px; HEIGHT: 24px } #uboxstyle DIV.tag_select_open { PADDING-RIGHT: 10px; DISPLAY: block; PADDING-LEFT: 10px; BACKGROUND: url(http://www.geekso.com/attachment/ubox-select.gif) no-repeat 0px -48px; PADDING-BOTTOM: 0px; WIDTH: 230px; COLOR: #79a2bd; LINE-HEIGHT: 24px; PADDING-TOP: 0px; HEIGHT: 24px } #uboxstyle UL.tag_options { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BACKGROUND: url(http://www.geekso.com/attachment/ubox-select.gif) no-repeat right bottom; PADDING-BOTTOM: 5px; MARGIN: 0px; WIDTH: 250px; PADDING-TOP: 0px; LIST-STYLE-TYPE: none; POSITION: absolute } #uboxstyle UL.tag_options LI { PADDING-RIGHT: 10px; DISPLAY: block; PADDING-LEFT: 10px; BACKGROUND: url(http://www.geekso.com/attachment/ubox-select.gif) repeat-y -250px 0px; PADDING-BOTTOM: 0px; WIDTH: 230px; COLOR: #79a2bd; LINE-HEIGHT: 24px; PADDING-TOP: 0px; HEIGHT: 24px; TEXT-DECORATION: none } #uboxstyle UL.tag_options LI.open_hover { BACKGROUND: url(http://www.geekso.com/attachment/ubox-select.gif) no-repeat 0px -72px; COLOR: #fff } #uboxstyle UL.tag_options LI.open_selected { BACKGROUND: url(http://www.geekso.com/attachment/ubox-select.gif) no-repeat 0px -96px; COLOR: #fff } </STYLE> <SCRIPT> var selects = document.getElementsByTagName('select'); var isIE = (document.all && window.ActiveXObject && !window.opera) ? true : false; function $(id) { return document.getElementById(id); } function stopBubbling (ev) { ev.stopPropagation(); } function rSelects() { for (i=0;i<selects.length;i++){ selects[i].style.display = 'none'; select_tag = document.createElement('div'); select_tag.id = 'select_' + selects[i].name; select_tag.className = 'select_box'; selects[i].parentNode.insertBefore(select_tag,selects[i]); select_info = document.createElement('div'); select_info.id = 'select_info_' + selects[i].name; select_info.className='tag_select'; select_info.style.cursor='pointer'; select_tag.appendChild(select_info); select_ul = document.createElement('ul'); select_ul.id = 'options_' + selects[i].name; select_ul.className = 'tag_options'; select_ul.style.position='absolute'; select_ul.style.display='none'; select_ul.style.zIndex='999'; select_tag.appendChild(select_ul); rOptions(i,selects[i].name); mouseSelects(selects[i].name); if (isIE){ selects[i].onclick = new Function("clickLabels3('"+selects[i].name+"');window.event.cancelBubble = true;"); } else if(!isIE){ selects[i].onclick = new Function("clickLabels3('"+selects[i].name+"')"); selects[i].addEventListener("click", stopBubbling, false); } } } function rOptions(i, name) { var options = selects[i].getElementsByTagName('option'); var options_ul = 'options_' + name; for (n=0;n<selects[i].options.length;n++){ option_li = document.createElement('li'); option_li.style.cursor='pointer'; option_li.className='open'; $(options_ul).appendChild(option_li); option_text = document.createTextNode(selects[i].options[n].text); option_li.appendChild(option_text); option_selected = selects[i].options[n].selected; if(option_selected){ option_li.className='open_selected'; option_li.id='selected_' + name; $('select_info_' + name).appendChild(document.createTextNode(option_li.innerHTML)); } option_li.onmouseover = function(){ this.className='open_hover';} option_li.onmouseout = function(){ if(this.id=='selected_' + name){ this.className='open_selected'; } else { this.className='open'; } } option_li.onclick = new Function("clickOptions("+i+","+n+",'"+selects[i].name+"')"); } } function mouseSelects(name){ var sincn = 'select_info_' + name; $(sincn).onmouseover = function(){ if(this.className=='tag_select') this.className='tag_select_hover'; } $(sincn).onmouseout = function(){ if(this.className=='tag_select_hover') this.className='tag_select'; } if (isIE){ $(sincn).onclick = new Function("clickSelects('"+name+"');window.event.cancelBubble = true;"); } else if(!isIE){ $(sincn).onclick = new Function("clickSelects('"+name+"');"); $('select_info_' +name).addEventListener("click", stopBubbling, false); } } function clickSelects(name){ var sincn = 'select_info_' + name; var sinul = 'options_' + name; for (i=0;i<selects.length;i++){ if(selects[i].name == name){ if( $(sincn).className =='tag_select_hover'){ $(sincn).className ='tag_select_open'; $(sinul).style.display = ''; } else if( $(sincn).className =='tag_select_open'){ $(sincn).className = 'tag_select_hover'; $(sinul).style.display = 'none'; } } else{ $('select_info_' + selects[i].name).className = 'tag_select'; $('options_' + selects[i].name).style.display = 'none'; } } } function clickOptions(i, n, name){ var li = $('options_' + name).getElementsByTagName('li'); $('selected_' + name).className='open'; $('selected_' + name).id=''; li[n].id='selected_' + name; li[n].className='open_hover'; $('select_' + name).removeChild($('select_info_' + name)); select_info = document.createElement('div'); select_info.id = 'select_info_' + name; select_info.className='tag_select'; select_info.style.cursor='pointer'; $('options_' + name).parentNode.insertBefore(select_info,$('options_' + name)); mouseSelects(name); $('select_info_' + name).appendChild(document.createTextNode(li[n].innerHTML)); $( 'options_' + name ).style.display = 'none' ; $( 'select_info_' + name ).className = 'tag_select'; selects[i].options[n].selected = 'selected'; } window.onload = function(e) { bodyclick = document.getElementsByTagName('body').item(0); rSelects(); bodyclick.onclick = function(){ for (i=0;i<selects.length;i++){ $('select_info_' + selects[i].name).className = 'tag_select'; $('options_' + selects[i].name).style.display = 'none'; } } } </SCRIPT> <META content="MSHTML 6.00.2900.3199" name=GENERATOR> </HEAD> <BODY> <FORM id=form name=form action="" method=post> <BR> <BR> <DIV id=uboxstyle> <SELECT id=language name=language> <OPTION value=English selected>请选择。</OPTION> <OPTION value=简体中文>简体中文</OPTION> <OPTION value=日本語>日本語</OPTION> <OPTION value=http://www.geekso.com>这一技客</OPTION> </SELECT> </DIV> <BR> <BR> </DIV> </FORM> </BODY> </HTML>
提示:您可以先修改部分代码再运行
把本文网址发给朋友
自动转成UBB代码发到论坛
加入收藏夹
相关日志
Javascript操作Select和Option
CSS 兼容ie 6 ie7 firefox[转]
鼠标经过链接当中title的出提示层的效果qTip CSS Tooltips
CSS hack:区分IE6,IE7,firefox
对单选按钮radio进行CSS样式处理
Tags:
select
,
样式
,
css
,
下拉列表
评论(1)
|
kekehu
发表于
资源分享
|
引用(0)
|
阅读(1953)
引用功能被关闭了。
收
藏
到
网
摘
:
QQ书签
Google书签
手机漫游费上限标准3月1日起下降
恒源祥十二生肖广告-暴强!
krosa
2008/05/07 09:56
牛!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
分页: 1/1
1
发表评论
表情
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称
密码
游客无需密码
网址
电邮
[注册]
日志标题
日志全文
评论引用
所有留言
Tags
分类
返回首页
我的作品
一些锁事
技术文章
资源分享
文章列表
关于站长
商品推荐
最新日志
php生成缩略图类
开发计划
Javascript操作Selec...
动态改变input类型(type)...
2009年部分节假日安排的通知
extjs扯谈(转)
欢乐正前方动漫版在线观看
把链接的汉字进行转换-urlenc...
钢铁侠下载,钢铁侠在线观看地址-中...
阿龙-话说天下-北京文艺广播87....
支持我
最新评论
gringringrinzanza...
thumbdownthumbdow...
zanzanzan太牛了。。。爱死...
为什么启动那么慢
谢谢
zan
bad
zan
zan
envy
链接
盛世东方
吾爱媛
云在青天水在瓶
萧萧蜗牛的壳
地大饰家
seehao
听者有心
PandaKing's Favorites
经典笑话
白看电影网
电脑主题网
中国电脑急救网
1月互动社区
飞儿宝贝
其他
登入
注册
申请链接
日志 RSS
评论 RSS
XHTML 1.0
京ICP备06015203号