【发布时间】:2019-08-27 14:04:58
【问题描述】:
当 af-notification__content div 悬停时,标题 (af-notification__title)、说明 (af-notification__description) 和日期 (af-notification__date) 文本颜色应变为黑色。
我在内容 div 中添加了“颜色:黑色”
.af-notification__content :hover {
color: black;
background-color: #dfeaed;
}
<div class="af-notification" *ngFor="let item of items; let i = index" [class.toggled]="toggled">
<div class="af-notification__content" [class.delete]="delete">
<button (click)="deleteWidget(i)" class="btn-close">delete</button>
<span class="af-notification__title" [class.read]="item['read'] == true">{{ item['title'] }}</span>
<span class="af-notification__description">{{ item['description'] }}</span>
<span class="af-notification__date">
{{ item['date'] }} {{ item['time'] }}
</span>
</div>
</div>
https://stackblitz.com/edit/angular-9quulu
如果我将鼠标悬停在 af-notification__content div 上,所有文本都应变为黑色。目前,只有将鼠标悬停在每个单独的文本范围上时,文本才会变为黑色。 在这种情况下使用 ::ng deep 会是一个不错的选择吗?
【问题讨论】:
-
也许删除空间:
.af-notification__content:hover -
@TemaniAfif 这似乎不起作用
-
CSS 中
.af-notification__content和:hover之间的空格字符是后代组合器/选择器。 developer.mozilla.org/en-US/docs/Web/CSS/Descendant_combinator -
.af-notification__content:hover *也许? -
您可以为此添加相关的最小 html 代码吗?