hanging-punctuation

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

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

元素第一行開頭處的開括號或引號懸掛。這適用於

  • Unicode 類別 PsPfPi 中的所有字元
  • 引號 U+0027 APOSTROPHE (') 和 U+0022 QUOTATION MARK (")。
last

元素最後一行結尾處的閉括號或引號懸掛。這適用於

  • Unicode 類別 PePfPi 中的所有字元
  • 引號 U+0027 APOSTROPHE (') 和 U+0022 QUOTATION MARK (")。
allow-end

如果句號或逗號在對齊之前無法容納,則懸掛在行尾。

允許懸掛的句號和逗號包括

  • U+002C,逗號
  • U+002E,句號
  • U+060C,阿拉伯逗號
  • U+06D4,阿拉伯句號
  • U+3001,表意逗號
  • U+3002,表意句號
  • U+FF0C,全形逗號
  • U+FF0E,全形句號
  • U+FE50,小逗號
  • U+FE51,小表意逗號
  • U+FE52,小句號
  • U+FF61,半形表意句號
  • U+FF64,半形表意逗號

使用者代理可以包含額外的字元。

正式定義

初始值none
應用於所有元素
繼承性
計算值同指定值
動畫型別離散

正式語法

hanging-punctuation = 
none |
[ first || [ force-end | allow-end ] || last ]

示例

設定開引號和閉引號懸掛

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 Text Module Level 3
# hanging-punctuation-property

瀏覽器相容性

另見