我想仅在锚标记完全独立时才选择它们,这样我可以使它们看起来像按钮,而不会使句子中的锚看起来像按钮。我不想添加额外的类,因为这是在 CMS 中进行的。
我最初是在尝试这个:
article p a:first-child:last-child {
background-color: #b83634;
color: white;
text-transform: uppercase;
font-weight: bold;
padding: 4px 24px;
}
但它不起作用,因为文本内容不被视为标准:first-child
or :last-child
.
我想匹配
<p><a href='#'>Link</a></p>
but not
<p><a href='#'>Link</a> text content</p>
or
<p>text content <a href='#'>Link</a></p>
这可以用 CSS 实现吗?
简单的答案是:不,你不能.
正如所解释的here, here and here,没有适用于文本节点的 CSS 选择器。
如果您可以使用 jQuery,请查看包含选择器.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)