CSS text-emphasis-position 属性

CSS text-emphasis-position 语法

在 CSS 中,text-emphasis-position 属性用于定义文本 “强调标记的位置”。需要注意的是,如果没有足够空间来放置强调标记,则会增加行高。

语法:

text-emphasis-position: 关键字;

说明:

text-emphasis-position 属性取值有 4 种,如下表所示。

text-emphasis-position 属性取值
取值 说明
over right(默认值) 上方靠右
over left 上方靠左
under right 下方靠右
under left 下方靠左

注意,text-emphasis-position 属性只有当 text-emphasis-style 属性的值不是 none 时才会生效。

text-emphasis “家族”

text-emphasis “家族” 其实有 4 个属性,分别如下。

需要注意的是,text-emphasis 只是 text-emphasis-color 和 text-emphasis-style 这 2 个属性的简写,并不包括 text-emphasis-position。

CSS text-emphasis-position 摘要

属于 CSS 文本属性
使用频率
是否继承
默认值 取决于 writing-mode 和 direction
兼容性 查看
官方文档 查看
MDN 查看

CSS text-emphasis-position 示例

接下来,我们通过一个简单的例子来讲解一下 CSS text-emphasis-position 属性是如何使用的。

示例:text-emphasis-position 基本用法

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <style>
        p {
            font-size: 30px;
            text-emphasis: circle red;
        }
        p:nth-of-type(1) { text-emphasis-position: over right; }
        p:nth-of-type(2) { text-emphasis-position: over left; }
        p:nth-of-type(3) { text-emphasis-position: under right; }
        p:nth-of-type(4) { text-emphasis-position: under left; }
    </style>
</head>
<body>
    <p>绿叶网ABC</p>
    <p>绿叶网ABC</p>
    <p>绿叶网ABC</p>
    <p>绿叶网ABC</p>
</body>
</html>

页面效果如下图所示。

text-emphasis-position 示例

提示: 强调标记的首选语言取决于语言,比如 “中文” 首选位置为 under right,“日语” 首选位置为 over right。

上一篇: text-emphasis-color

下一篇: text-orientation

给站长反馈

绿叶网正在不断完善中,小伙伴们如果发现任何问题,还望多多给站长反馈,谢谢!

邮箱:lvyenet@vip.qq.com

「绿叶网」服务号
绿叶网服务号放大
关注服务号,微信也能看教程。
绿叶网服务号