Use pure css to change the default style of the select box in the drop-down list-dehua. Chen

Source: Internet
Author: User
Use pure css to change the default style of the select box in the drop-down list-dehua. Chen to clear the default drop-down box style of the browser, apply your own style, and attach a picture with a small arrow on the right.

1 select {2/* the borders in Chrome and Firefox are different, so rewrite */3 border: solid 1px #000; 4 5: clear the default select box style */6 appearance: none; 7-moz-appearance: none; 8-webkit-appearance: none; 9/* show a small arrow in the middle right of the Selection box */10 background: url ("http://ourjs.github.io/static/2015/arrow.png") no-repeat scroll right center transparent; 11/* Leave a position for the drop-down arrow to avoid text overwriting */12 padding-right: 14px; 13} 14/* clear the default selection box style of ie, hide the drop-down arrow */15 select:-ms-expand {display: none ;}

IE8/9 does not support the appearance: none CSS attribute. To support this attribute, you may need a very special method. Refer to SF: we need to add a parent container for it, the container is used to overwrite the small arrow, and then add a small offset to the right or the width is greater than the parent element for the select statement. If the CSS attribute of the parent class is set to invisible to the excess part, the small arrow is overwritten. Then add a background image to the parent container.

1 

2 3 what4 the5 hell6 7

1 #parent {background: url('yourimage') no-repeat; width: 100px;2 height: 30px; overflow: hidden;}3 #parent select {background: transparent; border: none; padding-left: 10px; width: 120px; height: 100%;}

Transparent input background code

Background-color: transparent;

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.