基于多个类选择元素

编程入门 行业动态 更新时间:2024-10-24 18:27:47
本文介绍了基于多个类选择元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个样式规则,当它有两种样式时,我想应用于标记。有没有任何方式来执行这个没有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?

更多推荐

基于多个类选择元素

本文发布于:2023-11-09 05:34:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571514.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   元素

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!