怎么height跟line-height相等时在IE7,Chrome文字居中显示,但Firefox却紧贴input顶部?
- HTML code
<!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" /> <style type="text/css"> <!-- #inp{ font-size:13px; width:50%; height:30px; line-height:30px; border:1px solid #929292; overflow: hidden; } --> </style> </head> <body> <input type="text" name="title" value="why" id="inp" /> </body> </html>
------解决方案--------------------
不要用height和line-height
用padding吧,代码如下
- HTML code
<!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" /> <style type="text/css"> <!-- #inp{ font-size:13px; width:50%; border:1px solid #929292; overflow: hidden; [color=#FF0000] padding-top:10px; padding-bottom:10px;[/color] } --> </style> </head> <body> <input type="text" name="title" value="why" id="inp" /> </body> </html>
------解决方案--------------------
FF不支持INPUT的LINE-HEIGHT
------解决方案--------------------
input控件的样式比较麻烦
还跟<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
有关系
你可以设padding