The best presets of select are compatible with select_HTML/Xhtml _ web page creation in various browsers.

Source: Internet
Author: User
We know that the properties of the select tag in each browser are different from those supported by each browser, which leads to a different display in each browser, the following describes how to support the CSS attributes of the main shape to create a fully compatible select statement. For more information, see, as a result, the select selection box is displayed in different browsers. Next we will create a fully compatible select by supporting the CSS attributes of the main shape.
I wrote a DEMO for the select height, padding, and line-height using the control variable method to test three cases in different browsers: height.100.padding. 0, height. no. padding.100, no. height. no. padding. The result is shown in links to images in various browsers. DEMO appearance

We can obtain the following research attributes.

Ie6

Ie7

Ie8

Ie9

Ff

Ch

Sf

Op

Default height

22px

22px

19px

20px

19px

19px

Height

F

T

T

T

T

T

F

T

Padding

F

F

T

T

T

T

F

T

Line-height

F

F

F

F

F

F

T

F

Vertical text Center

T

T

T

F

F

T

T

T


Through the summary of the above research results, we know that IE6 is set to a fixed height of 22px regardless of the settings, and other browsers except safari support the height attribute, then we set the height: 22px. Now let's fix the safari browser. We found that only safari supports the line-height attribute, so we can use line-height to correct its height to 22px, set line-height: 22px when font-size is 12 PX, and the text in FF and IE9 is not centered. Set padding: 2px 0, we found that FF and IE9 are both centered, but the select height of Each browser has not increased, so here is a bit of doubt, when the height is set, does the padding of a small number increase the overall height?
The following is an example of fully compatible code.

The Code is as follows:






Demo




Demonstration Question 1 Demonstration Question 2 Demonstration question 3 Demonstration question 4 Demonstration Question 5



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.