Add a style (no script) for select using pure css to implement _ HTML/Xhtml _ webpage Creation

Source: Internet
Author: User
Change the default select style, which is simulated by ul and li in general cases. The Jquery plug-in is also like this. Next we will introduce a method that does not write scripts and is implemented with only pure css. In the IE series, when selecting a certain option will have a background color block, IE7-IE10 has this bug, interested friends can refer to Ah change select default style, generally, ul and li are used for simulation.
Many Jquery plug-ins use this method to change the default select style.
According to my brother, this method cannot obtain data after form is submitted. After experiment, different JS/Jquery plug-ins are used, and the same result is returned: data cannot be obtained.

Next, let's look at a blog written by a foreigner. We use the css style to add a p to the select field and set the select width to be less than the width of the parent p, then, you can change the default select arrow style by setting the background attribute of p.
This method is a good method. without writing a script, you only need to implement it with simple css.

But this method is also flawed, is in the IE series, when selecting an option will have a background color block, IE7-IE10 has this bug.
In Opera, the background image set to p is not displayed, that is, the select drop-down arrow is not displayed. I don't know why.
The following code

The Code is as follows:



AAAAAAAAAAA Bbbbbbbbbbbbb CCCCCCCCCCC DDDDDDDDDDD




The Code is as follows:


. Select_style {width: 240px; height: 30px; overflow: hidden; background: url (../images/arrow.png) no-repeat 215px;
Border: 1px solid # ccc;
-Moz-border-radius: 5px;/* Gecko browsers */
-Webkit-border-radius: 5px;/* Webkit browsers */
Border-radius: 5px;
}
. Select_style select {padding: 5px; background: transparent; width: 268px; font-size: 16px; border: none; height: 30px;
-Webkit-appearance: none;/* for Webkit browsers */
}

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.