CSS选择包含加号“+”的类。 [英] CSS select a class containing plus sign "+"
本文介绍了CSS选择包含加号“+”的类。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过包含加号 +
?的类名选择元素?
Eg
.frme_150 + 1 {background-position:150px 1px;}
使用JavaScript更改加值,是否可以使用 +
选择器名称?
解决方案
您需要 escape 加号,因为它具有 \ 特殊含义 css-escapes#0frme_150 + 1rel =nofollow>如下:
.frme_150 \ + 1 {
background-position:150px 1px;
}
工作演示 。
或转义 '
至 '\2b'
或 '\00002b'
(六个十六进制数字)
此外,您也可以使用 CSS属性选择器 :
[class =frme_150 + 1] {background-position:150px 1px; }
工作演示 。
How can I select an element by class name containing a plus sign +
?
E.g.
.frme_150+1 {background-position: 150px 1px;}
The plus value is changed by using JavaScript, is this possible to use +
character in selector name?
解决方案
You'd need to escape the plus sign as it has a special meaning in CSS, by using a leading backslash \
as follows:
.frme_150\+1 {
background-position: 150px 1px;
}
Or escape the '+'
to '\2b '
or '\00002b'
(six hexadecimal digits)
Also, you can achieve this by using CSS Attribute Selector:
[class="frme_150+1"] { background-position:150px 1px; }
这篇关于CSS选择包含加号“+”的类。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文