Result
SVGを使ってあります
css
.btn {/*ボタン装飾*/ position: relative; display: inline-block; width: 166px; height: 45px; font-size: 14px; line-height: 45px; text-align: center; color: #ffffff; cursor: pointer; overflow: hidden; } .btn svg {/*svg配置*/ position: absolute; top: 0; left: 0; } .btn svg rect {/*基本図形stroke設定*/ stroke: #ffffff; stroke-width: 6; stroke-dasharray: 422, 0; stroke-dashoffset: 0; transition: all 900ms cubic-bezier(0.19, 1, 0.22, 1); } .btn:hover svg rect {/*ホバー時に挙動を変更*/ stroke-width: 10; stroke-dasharray: 110, 312; stroke-dashoffset: 183; }
html
<div class="btn"> <svg> <rect x="0" y="0" fill="none" width="166" height="45" /> </svg> foo bar </div>