是否可以在属性选择器的中间使用CSS通配符? [英] Is it possible to use a CSS wildcard in the middle of an attribute selector?
问题描述
我有一些生成的CSS,并希望使用一些css可以选择
< p id =loremIndexIpsum>此处的文字< / p>
使用 lorem
和 Ipsum
忽略索引
。类似的内容:
p#lorem * Ipsum
{
}
我可以生成更多的类,但想知道这是否可能与CSS。
解决方案您不能使用这样的通配符,而是要获得所需的结果(ID以
lorem
开头,Ipsum
),您可以使用属性如下所示:p [id ^ =lorem] [id $ =Ipsum]
请记住,通过链接多个属性选择器
p
类型选择器),您在同一个元素上与它们进行AND匹配。
a href =http://jsfiddle.net/BoltClock/vpZmq/1 =noreferrer> jsFiddle demo
I have some generated CSS and would like to use some css that could select e.g.
<p id="loremIndexIpsum">Text in here</p>
Using on
lorem
andIpsum
disregardingIndex
. Something similar to:p#lorem*Ipsum { }
I can generate some more classes, but wondered if this was possible with CSS.
解决方案You can't use a wildcard like that, but to get the desired result (ID starts with
lorem
and ends withIpsum
) you can use the attribute starts-with and ends-with selectors instead, like so:p[id^="lorem"][id$="Ipsum"]
Remember that by linking multiple attribute selectors like this (along with the
p
type selector), you're doing an AND match with all of them on the same element.这篇关于是否可以在属性选择器的中间使用CSS通配符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!