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 通配符?
基础教程推荐
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
