We know that the properties of the select tag in each browser and the support of each browser are somewhat different, which causes the display of the select box in each browser to be different. Next, we will create a fully compatible select by supporting the main appearance CSS properties. I wrote a DEMO for the select's height, padding, and line-height using the control variable method to test three situations on various browsers: height.100.padding.0, height.no.padding.100, no.height.no.padding. The results are shown in the linked images. The DEMO appearance of each browser ![]() We can derive the following research properties.
Through the above research results attribute summary, we know that IE6 has a fixed height of 22px no matter how it is set, and other browsers except Safari support the height attribute, so we set height:22px. Now let's correct 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. Under the premise of font-size being 12px, we set line-height:22px. Finally, the text in FF and IE9 is not centered. We set padding:2px 0 for it. We found that FF and IE9 are centered, but the height of the selects in each browser has not increased. So here is a question. When the height is set, the padding of a small number does not increase the overall height? The following is a fully compatible code example. Copy code The code is as follows:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>demo</title> <style> *{padding:0; margin:0} body{font-size:12px} select{height:22px; line-height:18px; padding:2px 0} </style> </head> <body> <div style="margin-top:20px; margin-left:20px; background:#000"> <select> <option>Demonstration Question 1</option> <option>Demonstration Question 2</option> <option>Demonstration Question 3</option> <option>Demonstration Question 4</option> <option>Demonstration Question 5</option> </select> </div> </body> </html> |
<<: Using text shadow and element shadow effects in CSS
>>: How many times will multiple setStates in React be called?
query_cache_limit query_cache_limit specifies the...
Preface I recently encountered some problems at w...
Big pit, don't easily delete the version of P...
Table of contents 1. Spark vs. Hadoop 1.1 Disadva...
top command is the best command that everyone is ...
1. Test environment name Version centos 7.6 docke...
Preface In Java programming, most applications ar...
I recently used Docker to upgrade a project. I ha...
Recently, I have been working on a large-screen d...
1. Software Download MySQL download and installat...
Step 1: yum install httpd -y #Install httpd servi...
Table of contents Preface Bubble Sort Basic Algor...
Table of contents 1. Installation 2. Introducing ...
This article shares with you the installation tut...
I am going to review Java these two days, so I wr...