本文介绍了基于多个类选择元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个样式规则,当它有两种样式时,我想应用于标记。有没有任何方式来执行这个没有JavaScript?换句话说:
I have a style rule I want to apply to a tag when it has two styles. Is there any way to perform this without JavaScript? In other words:
<li class='left ui-class-selector'>我想只应用我的样式规则 c> li 同时应用了 .left 和 .ui-class-selector
I want to apply my style rule only if the li has both .left and .ui-class-selector classes applied.
推荐答案你的意思是两个类? 链选择器(它们之间没有空格):
You mean two classes? "Chain" the selectors (no spaces between them):
.class1.class2 { /* style here */ }这将选择 class1 也有 class2 。
在您的情况下:
li.left.ui-class-selector { }官方文件: CSS2类选择器。
作为 akamike 指出此方法的问题在Internet Explorer 6中,您可能需要阅读以下内容:在IE6 CSS中使用双类?
As akamike points out a problem with this method in Internet Explorer 6 you might want to read this: Use double classes in IE6 CSS?
更多推荐
基于多个类选择元素
发布评论