nmd*_*mdr 14 javascript css internet-explorer css-selectors internet-explorer-6
我工作的其中一个项目使用CSS"属性"选择器[att]
ie6不支持:IE6中 支持CSS选择器(查找文本"属性选择器")
是否有任何解决方法/黑客当然是有效的html/css来克服这个问题?
nic*_*ckf 26
遗憾的是,如果不使用一堆无关的类选择器来编写HTML,这是不可能的.
我建议你设计你的网站,以便你的完全有效的CSS适用于使用现代浏览器的人,并且它仍然可以在IE6中使用,尽管在视觉上不太正确.您只需要在让您的网站升级到标准之间找到适当的平衡,并为不升级的用户向后弯腰.这是一个破碎的浏览器,对待它.
Rex*_*x M 20
由于IE6基本上仅限于:
你唯一的选择是:
我发现利用通过用空格分隔多个类来为元素分配多个类的能力非常有用: class="foo bar"
如果你想在IE6中使用属性选择器,你可以使用Dean Edward IE.js. http://dean.edwards.name/IE7/
这将使IE 5+表现得更像IE7
supports the following CSS selectors: parent > child adjacent + sibling adjacent ~ sibling [attr], [attr="value"], [attr~="value"] etc .multiple.classes (fixes bug) :hover, :active, :focus (for all elements) :first-child, :last-child, only-child, nth-child, nth-last-child :checked, :disabled, :enabled :empty, :contains(), :not() :before/:after/content: :lang()
我没有IE6(使用IE7)所以我不能说它有用,但试一试
您可以使用Internet Explorer CSS表达式结合安全下划线("_",IE6和更早版本)CSS hack:
/* Adds dotted bottom border to `<ABBR>` with a `title` attribute. */
abbr {
_border-bottom: expression(this.title ? '1px dotted' : 'none');
}
abbr[title] {
border-bottom: 1px dotted;
}
Run Code Online (Sandbox Code Playgroud)
我确实理解,你确实要求"有效"的CSS,但是如果上面的CSS破解了你,请阅读有关安全CSS黑客的信息.
以上可以改为:
.ie6 abbr {
_border-bottom: expression(this.title ? '1px dotted' : 'none');
}
abbr[title] {
border-bottom: 1px dotted;
}
Run Code Online (Sandbox Code Playgroud)
那就是如果您的HTML开头为:
<!--[if lt IE 7]><html class="ie6"><![endif]-->
<!--[if IE 7]> <html class="ie7"><![endif]-->
<!--[if IE 8]> <html class="ie8"><![endif]-->
<!--[if gt IE 8]><!--><html><!--<![endif]-->
Run Code Online (Sandbox Code Playgroud)