我想在用户键入错误内容时将轮廓颜色放入文本框。问题是 IE8 不支持 outline
属性(至少我测试没有成功)所以我改用 border
:
但我想对 IE8 使用 border
,对支持它的浏览器使用 outline
。
.myclass
{
border: ; // IE8 should use this
outline: ; // Browser that support it must ignore the above one and get this.
}
我用 IE8 和 Chrome 进行了测试,这两个属性都在 Chrome 中应用,而在 IE8 中只应用了边框。
例子:
.myclass
{
border: 1px solid red;
outline:#00FF00 dotted thick;
}
谢谢。
最佳答案
谁说IE8不支持outline
属性?
如果你想为 IE 和其他浏览器使用不同的样式,请使用 IE 特定的样式表,使用 IE 特定的 cstylesheet 注释
<!-- This will be ignored by all browsers but IE -->
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="ie-only.css" />
<![endif]-->
或针对任何特定的 IE 版本
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="ie7.css">
<![endif]-->
或者在你的页面中使用这个
<!--[if IE 8]>
<style>
/* Styles goes here */
</style>
<![endif]-->
关于html - 在一个 CSS 类中组合不同的用户代理属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13514117/