CSS Nite
『CodeGridから読み解くイマドキのCSS 第二弾』
ruby, rt, rp
春
春
rb要素は削除され、非標準となった
rubyrtrp
春
春
rp要素について
春
春
ruby-positionプロパティ
ルビ関係のCSSプロパティは
いくつかあるが、まずはこれを
覚えておきたい
.over {
-webkit-ruby-position: before; /* Safari */
ruby-position: over;
}
.under {
-webkit-ruby-position: after; /* Safari */
ruby-position: under;
}
春
春
春
.under {
-webkit-ruby-position: after;
ruby-position: under;
}
.under > ruby {
-webkit-ruby-position: before;
ruby-position: over;
}
春
text-emphasisプロパティ
text-emphasisはショートハンドプロパティ
text-emphasis-styletext-emphasis-color
em {
font-style: normal; /* 初期スタイルをリセット */
-webkit-text-emphasis: dot; /* Chrome */
text-emphasis: dot;
}
…
窓越しにソメイヨシノを見ながら…
em {
font-style: normal;
-webkit-text-emphasis: dot open;
text-emphasis: dot open;
}
em {
font-style: normal;
-webkit-text-emphasis: "★";
text-emphasis: "★";
}
em {
font-style: normal;
color: tomato;
-webkit-text-emphasis: dot;
text-emphasis: dot;
}
em {
font-style: normal;
color: inherit;
-webkit-text-emphasis: dot tomato;
text-emphasis: dot tomato
}
もうすぐ
春
ですね
em {
font-style: normal;
-webkit-text-emphasis: dot;
text-emphasis: dot
}
hanging-punctuationプロパティfirst、last、allow-endまたはforce-endforce-endはサポートなし
「もうすぐ春ですね」
□窓越しにソメイヨシノを見ながら、彼は言葉を紡いだ。
p {
margin-inline: auto;
width: 8em;
background-color: antiquewhite;
hanging-punctuation: first last allow-end;
}
first
last
end
endではぶら下げられない
「もうすぐ春ですね」
□窓越しにソメイヨシノを見ながら、彼は言葉を紡いだ。
firstは1字下げに使える?
「もうすぐ春ですね」
窓越しにソメイヨシノを見ながら、彼は言葉を紡いだ。
p {
margin-inline: auto;
width: 9em;
background-color: antiquewhite;
hanging-punctuation: first last allow-end;
text-indent: 1em;
}
「もうすぐ春ですね」
窓越しにソメイヨシノを見ながら、彼は言葉を紡いだ。
lastとallow-endは未サポート環境に影響を及ぼさないfirstは場合によっては影響があるので注意が必要以上を考慮すれば、使ってもよさそう
「もうすぐ
春ですね」
区分分断の変形規則
「もうすぐ
春ですね」
(中国語などもあるので、正確には日本語に限らない)
日本語HTMLは1行が長くなりがち
区分分断の変形規則により、
これらが解消されると考えられる
text-spacingプロパティtext-autospaceという名前だったtext-autospaceとtext-trimの仕様が合体してtext-spacingへいろいろできます!
日本語で嬉しい機能を紹介
半角英数と日本語の文字との
間に1/4文字の空白を加える
(おおまかな表現。正確にはもっと複雑)
2021年11月19日のCSS Nite情報
p {
text-spacing: ideograph-alpha ideograph-numeric;
}
2021 年 11 月 19 日の CSS Nite 情報
text-spacing利用
行頭の開き括弧類や
行末にある閉じ括弧類の
空白を調整
p {
width: 9em;
background-color: antiquewhite;
}
「もうすぐ春ですね」
p {
width: 9em;
background-color: antiquewhite;
text-spacing: trim-start;
}
p {
width: 9em;
background-color: antiquewhite;
text-spacing: trim-start trim-end;
}
p {
width: 18em;
background-color: antiquewhite;
}
「もうすぐ春ですね」と彼は言ったが、「それは違う」と私は小声で反論した。
p {
width: 18em;
background-color: antiquewhite;
text-spacing: trim-start;
}
p {
width: 18em;
background-color: antiquewhite;
text-spacing: trim-start space-first;
}
連続する開き括弧類や
閉じ括弧類の空白を調整
p {
width: 25em;
background-color: antiquewhite;
}
「『春はあけぼの』清少納言の言葉だ」彼は言った。
「こうも遺した『夏は夜』」私は続ける。
「『秋は夕暮れ』・『冬はつとめて』」最後は二人で。
p {
width: 25em;
background-color: antiquewhite;
text-spacing: trim-adjacent;
}
CSS組版プロジェクト「Vivliostyle」
text-spacingのサポートを開始hanging-punctuationも対象バージョンは 2.12.0 (2021-11-13)
ありがとうございました