通过样式表对select类型的下拉列表进行美化,只适用于部分浏览器
演示效果一:
效果一:<br> <div style="width:108px; height:19px; overflow: hidden; border: 1 solid black"> <div style="position:absolute; left:-2; top:-2; width:171px; height:50px; clip: rect(2 108 19 2)"> <select name="select"> <option selected>sharejs.com</option> <option>分享JavaScript</option> <option>sharejs.com</option> <option>sharejs.com</option> </select> </div> </div>
演示效果2
效果二:<br> <div style="width:108px; height:19px; overflow: hidden; border: 1 solid black"> <div style="position:absolute; left:-2; top:-2; width:171px; height:50px; clip: rect(2 108 19 2)"> <select name="select" onFocus="this.parentElement.parentElement.style.borderColor='red'" onBlur="this.parentElement.parentElement.style.borderColor='black'"> <option selected>sharejs.com</option> <option>bbbbbbbbbbbb</option> <option>cccccccccccc</option> <option>dddddddddddd</option> </select> </div> </div>
说明:
在网页顶部,不能出现标准化代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">




