我对select的height、padding、line-height各自运用操纵自变量的方式写了个DEMO在各访问器上检测3种状况:height.100.padding.0、height.no.padding.100、no.height.no.padding,結果如 连接照片各访问器DEMO外型
大家能够得出下列科学研究特性。
ie6
ie7
ie8
ie9
ff
ch
sf
op
默认设置高宽比
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
文本竖直垂直居中
T
T
T
F
F
T
T
T
根据上述的科学研究成效特性汇总,大家了解IE6是不管怎样设定全是固定不动高宽比为22px不会改变的,而别的访问器除safari全是适用height特性的,那末大家设定 height:22px。那末如今大家调整1下safari访问器,,大家发现唯一safari适用line-height特性那末恰好能够运用line-height调整其高宽比为22px,在font-size为12px的前提条件下设定 line-height:22px,最终FF和IE9里边的文本不垂直居中,对其设置 padding:2px 0,大家发现FF和IE9都垂直居中了,可是各个访问器的select的高宽比也并沒有提升,那末这里有点疑惑,在高宽比设置的状况下,少量数据的padding不提升总体高宽比?
下面是全适配编码示例。
拷贝编码
编码以下:<!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⑻" />
<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>演试难题1</option>
<option>演试难题2</option>
<option>演试难题3</option>
<option>演试难题4</option>
<option>演试难题5</option>
</select>
</div>
</body>
</html>