デザイン上テキストが1行に限定されている場合のテキストの均等割りを確認します。
デモページはこちら
以下のhtml構造で確認します。
<p>text-align: justifyの場合</p>
<div class="div-parent">
<dl>
<div>
<dt class="style01">タイトル:</dt>
<dd>テキストテキストテキストテキスト</dd>
</div>
<div>
<dt class="style01">長いタイトル:</dt>
<dd>テキストテキストテキストテキスト</dd>
</div>
<div>
<dt class="style01">さらに長いタイトル:</dt>
<dd>テキストテキストテキストテキスト</dd>
</div>
</dl>
</div>
<p>text-align-last: justifyの場合</p>
<div class="div-parent">
<dl class="dl">
<div>
<dt class="style02">タイトル:</dt>
<dd>テキストテキストテキストテキスト</dd>
</div>
<div>
<dt class="style02">長いタイトル:</dt>
<dd>テキストテキストテキストテキスト</dd>
</div>
<div>
<dt class="style02">さらに長いタイトル:</dt>
<dd>テキストテキストテキストテキスト</dd>
</div>
</dl>
</div>
CSSは以下になります。text-align: justifyは複数行のテキストを最終行以外均等割りにします。1行のテキストは最終行と同じ扱いになるため均等割りできません。1行のテキストを均等割りする場合はtext-align-last: justifyを使用します。
.div-parent {
margin: 0 0 1em;
padding: 1em;
background: #fff;
overflow: hidden;
}
dl div {
display: flex;
}
dl div:not(:first-child) {
margin-top: 1em;
}
dt {
position: relative;
width: 9em;
flex-shrink: 0;
padding-right: 1em;
}
dt::after {
content: ":";
position: absolute;
top: 0;
right: 0;
}
.style01 {
text-align: justify;
}
.style02 {
text-align-last: justify;
}





