Is it possible to use a CSS wildcard in the middle of an attribute selector?(是否可以在属性选择器中间使用 CSS 通配符?)
问题描述
我有一些生成的 CSS,想使用一些可以选择的 CSS,例如
I have some generated CSS and would like to use some css that could select e.g.
<p id="loremIndexIpsum">Text in here</p>
在 lorem
和 Ipsum
上使用,而忽略 Index
.类似于:
Using on lorem
and Ipsum
disregarding Index
. Something similar to:
p#lorem*Ipsum
{
}
我可以生成更多类,但想知道这是否可以通过 CSS 实现.
I can generate some more classes, but wondered if this was possible with CSS.
推荐答案
不能使用这样的通配符,而是要得到想要的结果(ID 以 lorem
开头,以 结尾>Ipsum
) 你可以使用 属性开头和结尾选择器 相反,像这样:
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"]
请记住,通过像这样链接多个属性选择器(连同 p
类型选择器),您正在对同一元素上的所有属性选择器进行 AND 匹配.
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 演示
这篇关于是否可以在属性选择器中间使用 CSS 通配符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否可以在属性选择器中间使用 CSS 通配符?


- Flexslider 箭头未正确显示 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01