CSS 属性 text-emphasis-color 设置强调色。这个值也可以使用简写属性 text-emphasis 来设置。
CSS Demo: text-emphasis-color
text-emphasis-color: currentColor;
text-emphasis-color: red;
text-emphasis-color: rgba(90, 200, 160, 0.8);
<section id="default-example">
<p>
I'd far rather be
<span class="transition-all" id="example-element">happy than right</span>
any day.
</p>
</section>
p {
font: 1.5em sans-serif;
}
#example-element {
text-emphasis: filled;
}
语法
/* 初始值 */
text-emphasis-color: currentcolor;
/* <color> */
text-emphasis-color: #555;
text-emphasis-color: blue;
text-emphasis-color: rgb(90 200 160 / 80%);
text-emphasis-color: transparent;
/* 全局值 */
text-emphasis-color: inherit;
text-emphasis-color: initial;
text-emphasis-color: revert;
text-emphasis-color: revert-layer;
text-emphasis-color: unset;
取值
<color>- : 指定用作强调色的颜色。如果未定义,该值默认为
currentcolor。
- : 指定用作强调色的颜色。如果未定义,该值默认为
形式定义
形式语法
示例
设置自定义强调色和强调标记
CSS
em {
text-emphasis-color: green;
text-emphasis-style: "*";
}
HTML
<p>这是一个示例:</p>
<em>这里有强调标记!</em>
结果
设置自定义强调色和强调标记
规范
浏览器兼容性
参见
- <color> 数据类型
- 其他强调标记相关属性:text-emphasis-style、text-emphasis 和 text-emphasis-position
- 其他颜色相关属性:color、background-color、border-color、outline-color、text-emphasis-color、text-shadow、caret-color 和 column-rule-color
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
