悬挂标点
**hanging-punctuation
** CSS 属性指定标点符号是否应悬挂在文本行首或行尾。悬挂标点符号可以放置在行框之外。
语法
css
/* Keyword values */
hanging-punctuation: none;
hanging-punctuation: first;
hanging-punctuation: last;
hanging-punctuation: allow-end;
/* Two keywords */
hanging-punctuation: first allow-end;
hanging-punctuation: first last;
hanging-punctuation: last allow-end;
/* Three keywords */
hanging-punctuation: first allow-end last;
/* Global values */
hanging-punctuation: inherit;
hanging-punctuation: initial;
hanging-punctuation: revert;
hanging-punctuation: revert-layer;
hanging-punctuation: unset;
hanging-punctuation
属性可以用一个、两个或三个用空格分隔的值指定。
值
none
-
没有字符悬挂。
first
-
元素第一个格式化行的开头处的开括号或引号悬挂。这适用于
last
-
元素最后一个格式化行的结尾处的闭括号或引号悬挂。这适用于
allow-end
-
如果句号或逗号在行尾不适合在对齐之前,则将其悬挂。
允许悬挂的句号和逗号包括
U+002C
,COMMAU+002E
,FULL STOPU+060C
,ARABIC COMMAU+06D4
,ARABIC FULL STOPU+3001
,IDEOGRAPHIC COMMAU+3002
,IDEOGRAPHIC FULL STOPU+FF0C
,FULLWIDTH COMMAU+FF0E
,FULLWIDTH FULL STOPU+FE50
,SMALL COMMAU+FE51
,SMALL IDEOGRAPHIC COMMAU+FE52
,SMALL FULL STOPU+FF61
,HALFWIDTH IDEOGRAPHIC FULL STOPU+FF64
,HALFWIDTH IDEOGRAPHIC COMMA
用户代理可以包含其他字符。
正式定义
正式语法
示例
将开头和结尾引号设置为悬挂
HTML
html
<p>
«For a moment, nothing happened. Then, after a second or so, nothing continued
to happen.»
</p>
<p class="hanging">
«For a moment, nothing happened. Then, after a second or so, nothing continued
to happen.»
</p>
<p class="hanging right">
«For a moment, nothing happened. Then, after a second or so, nothing continued
to happen.»
</p>
CSS
css
p {
width: 15em;
border: 1px solid #cccccc;
font-size: 2rem;
font-style: italic;
margin: 1em;
}
p.hanging {
hanging-punctuation: first last;
}
p.right {
text-align: right;
}
结果
规范
规范 |
---|
CSS 文本模块第 3 级 # hanging-punctuation-property |
浏览器兼容性
BCD 表格仅在浏览器中加载