问题描述
我试图找到一个CSS选择器,可以帮助我区分这两种不同用法中的< var>
标记:
I'm trying to find a CSS selector that can help me distinguish between the <var>
tags in these 2 different usages:
<p><var>Foo</var></p>
和
<p>Some text <var>Foo</var> and more text</p>
基本上如果一个var有一个文本节点的兄弟节点,建议?
Basically if a var has a sibling that is a text node I need to style it differently. Suggestions?
推荐答案
这是不可能的,对不起。查看讨论:或官方W3C网页,你可以看到,即使CSS3不会支持这一点。 CSS甚至考虑DOM文本节点的唯一方法是:空的伪类选择空的元素,即没有孩子,也没有文本节点。
This is not possible, sorry. Check out that discussion: http://forum.userstyles.org/comments.php?DiscussionID=6 or the official W3C pages http://www.w3.org/TR/css3-selectors/ where you can see that even CSS3 will not support this. The only way CSS even considers the DOM text nodes is the :empty pseudo class selecting elements that are empty, i.e. do not have children neither text nodes.
这篇关于没有文本兄弟的元素的CSS选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!