CSS Simulation implementation Selec drop-down box

Source: Internet
Author: User

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> drop-down box </title>
<style>
* {
margin:0;
padding:0;
}

Body {
padding:50px 50px;
}

. btn-select {
position:relative;
Display:inline-block;
width:150px;
height:25px;
Background-color: #f80;
font:14px/20px "Microsoft Yahei";
Color: #fff;
}

. btn-select. Cur-select {
Position:absolute;
Display:block;
width:150px;
height:25px;
line-height:25px;
Background: #f80 URL (ico-arrow.png) no-repeat 125px Center;
text-indent:10px;
}

. btn-select:hover. Cur-select {
Background-color: #f90;
}

. btn-select Select {
Position:absolute;
top:0;
left:0;
width:150px;
height:25px;
opacity:0;
Filter:alpha (opacity:0;);
font:14px/20px "Microsoft Yahei";
Color: #f80;
}

. btn-select Select option {
text-indent:10px;
}

. btn-select Select Option:hover {
Background-color: #f80;
Color: #fff;
}
</style>

<body>
<form>
<a class= "Btn-select" id= "Btn_select" >
<span class= "Cur-select" > Please select </span>
<select>
<option> Option One </option>
<option> Options Two </option>
<option> option three </option>
<option> Options Four </option>
<option> Options Five </option>
</select>
</a>
</form>

<script>
var $$ = function (ID) {
return document.getElementById (ID);
}
Window.onload = function () {
var btnselect = $$ ("Btn_select");
var curselect = Btnselect.getelementsbytagname ("span") [0];
var oselect = btnselect.getelementsbytagname ("select") [0];
var aoption = btnselect.getelementsbytagname ("option");
Oselect.onchange = function () {
var Text=oselect.options[oselect.selectedindex].text;
curselect.innerhtml = text;
}
}
</script>
</body>

CSS Simulation implementation Selec drop-down box

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.