我有一个输入字段,如果可能的话,我希望它在 Internet Explorer 和 Firfox 中有两种不同的大小,我现在拥有的代码是:
div.search input#query {
width: 450px;
height: 24px;
font-size: 16px;
}
所以我想要这样的东西:
div.search input#query {
if internet explorer { width: 450px;}
else { width: 350px;}
height: 24px;
font-size: 16px;
}
谢谢
最佳答案
除了知道 conditional comments 的 Internet Explorer 之外,不可能以干净的方式(没有 CSS hack)直接定位特定的目标。 .
您可以将所有 IE 特定属性放入单独的样式表并将其嵌入主样式表之后(因此它会覆盖现有设置):
<!--[if IE]>
<link rel="stylesheet" href="ie.css" type="text/css">
<![endif]-->
您可能想要区分不同版本的 IE,因为 IE 6、7 和 8 在许多方面往往表现不同。
关于html - 根据浏览器更改输入字段的宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3185423/