开发者

Is it possible to use a CSS wildcard in the middle of an attribute selector?

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 and Ipsum disregarding Index. 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 with Ipsum) 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.

jsFiddle demo

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜