从 css 中排除 html 元素的更好方法



我找到了一个非常好的css代码,它将链接显示为突出显示的文本。现在我想让这种样式只应用于我网站上的帖子,所以在添加 css 样式后,我需要排除其他不适合我的帖子要求的元素,所以我最终得到了这个:

.entry-content p a:not(.et_pb_more_button):not(.et-pb-arrow-prev):not(.et-pb-arrow-next):not(.jp-relatedposts-post-title):not(.jp-relatedposts-post-a):not(#footnote_reference_container_collapse_button){
text-decoration:none;
border-bottom: 2px solid #bdef7a;
box-shadow: inset 0 -4px 0 #bdef7a;
color: inherit;
transition: background 0.1s cubic-bezier(.33,.66,.66,1);
}
.entry-content p a:hover:not(.et_pb_more_button):not(.et-pb-arrow-prev):not(.et-pb-arrow-next):not(.jp-relatedposts-post-title):not(.jp-relatedposts-post-a):not(#footnote_reference_container_collapse_button){
background: #bdef7a;
}

除了代码的丑陋之外,我仍然没有得到包含 ul 列表的div 中的预期结果,即使它在 .entry-content 类中也是如此。

现在我的问题是:实现预期结果的最佳方法是什么,为什么一个链接不显示样式?

如果您希望选择器应用于所有链接,而不仅仅是<p>元素内部的链接,请将选择器从:

.entry-content p a:not( 

.entry-content a:not(

最新更新