CSS selector based on element text?
Possible Duplicate:
Is there a CSS selector for elements containing certain text?
Is there a way to select an element in css based on element text?
ie:
li[text=*foo]
<li>foo</li>
<li>bar</li>
That probably doesn't work.
Edit: Also only need to support Chrome.
不直接使用CSS,你可以通过基于内部内容的JavaScript来设置CSS属性,但最终你仍然需要在CSS的定义中进行操作。
I know it's not exactly what you are looking for, but maybe it'll help you.
You can try use a jQuery selector :contains()
, add a class and then do a normal style for a class.
It was probably discussed, but as of CSS3 there is nothing like what you need (see also "Is there a CSS selector for elements containing certain text?"). You will have to use additional markup, like this:
<li><span class="foo">some text</span></li>
<li>some other text</li>
Then refer to it the usual way:
li > span.foo {...}
链接地址: http://www.djcxy.com/p/41412.html
上一篇: 将填充应用于跨两行的内联元素
下一篇: 基于元素文本的CSS选择器?