关于那个有很多问题,但没有一个对我有帮助。我希望普通链接为蓝色且带下划线,而文章标题应为红色且无下划线。这是代码:
a {
color: #337ab7;
text-decoration: underline;
}
.field.field--name-title{
color: #fffff0;
text-decoration: none;
}
我试过像这样组合:a.field.field--name-title
和 .field.field--name-title a
但它不起作用。
@编辑 添加 HTML,这是带有文章的 DIV:
<div class="views-row">
<article role="article" about="/de/link-test" class="node node--type-blog-entry node--promoted node--view-mode-teaser clearfix">
<div class="node__container">
<div class="node__main-content clearfix">
<header class="node__header">
<h2 class="node__title">
<a href="/de/link-test" rel="bookmark"><span class="field field--name-title field--type-string field--label-hidden">LINK TEST</span>
</a>
</h2>
</header>
<div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>tu jest link <a href="www.example.com">www.example.com</a></p>
</div>
<div class="node__links">
<ul class="links inline"><li class="node-readmore"><a href="/de/link-test" rel="tag" title="LINK TEST" hreflang="de">Weiterlesen<span class="visually-hidden"> über LINK TEST</span></a></li></ul> </div>
</div>
</div>
</article>
</div>
最佳答案
您定位到错误的选择器。 .field.field--name-title
是 anchor 标签内的跨度。根据您提供的标记,试试这个:
a {
color: #337ab7;
text-decoration: underline;
}
.node__title a {
color: #fffff0;
text-decoration: none;
}
更好的方法是给 anchor 标记一个类并定位它。
关于html - 链接仍带下划线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45588653/