SVG / 085
Stroke linecap
線の端の形
線の端を、平ら・丸・四角に描き分けます。
実際のHTML・CSSで描かれた見本です。
ひとつ試すなら
どこが変わるかを観察して、似た表現と見比べてみよう。
こんなときに
線画アイコンの統一感を整えるとき。
仕組みと使い方
roundとsquareは、線の座標より外側まで端が伸びます。
対応状況は使用する機能と端末により異なります。公式資料も参照してください。
表現名には通称や説明のための名称を含みます。デモと掲載コードはこの図鑑のオリジナルです。作者について
実装コードを見る
<style>
.sample{width:100%;height:100%;min-height:190px;display:grid;place-items:center;position:relative;overflow:hidden;box-sizing:border-box;font-family:Arial,'Hiragino Kaku Gothic ProN',Meiryo,sans-serif;color:#20211d;background:#f1f0e9;padding:22px}.sample *{box-sizing:border-box}.sample button,.sample input,.sample summary{font:inherit}.sample button,.sample summary,.sample label{touch-action:manipulation}.sample :focus-visible{outline:3px solid #6050bf;outline-offset:5px}.sample small{font-size:10px;line-height:1.5}.sample .editable{margin:0}.sample svg{max-width:100%;height:auto}
.sample svg{width:230px}
</style>
<div class="sample">
<svg viewBox="0 0 230 140" role="img" aria-label="butt、round、squareの線端の比較"><g stroke="#252622" stroke-width="14"><path d="M35 30H165" stroke-linecap="butt"/><path d="M35 70H165" stroke-linecap="round"/><path d="M35 110H165" stroke-linecap="square"/></g><g font-size="10" fill="#222"><text x="180" y="33">butt</text><text x="180" y="73">round</text><text x="180" y="113">square</text></g></svg>
</div>