ホームページ制作にあたり、自分自身が躓いたポイントをメモとして残しています。
SCSSでの記述です。
矢印つきボタンの作り方
【HTML】
<div class="c-button c-button--arrow">
<a href="#">ボタン</a>
</div>
【SCSS】
.c-button {
display: inline-flex;
justify-content: center;
align-items: center;
background-color: black;
font-size: 16px;
font-weight: bold;
color: white;
line-height: 1;
text-decoration: none;
}
.c-button--arrow {
padding: 15px 70px;
border-radius: 8px;
line-height: auto;
position: relative;
}
.c-button--arrow::before,
.c-button--arrow::after {
content: "";
position: absolute;
top: 0;
bottom: 0;
right: 10px;
margin: auto;
}
.c-button--arrow::before {
width: 14px;
height: 2px;
background-color: white;
}
.c-button--arrow::after {
width: 10px;
height: 10px;
border-top: 2px solid white;
border-right: 2px solid white;
transform: rotate(45deg);
}
→を上下真ん中配置するために重要なポイント
top: 0;
bottom: 0;
margin: auto;
絶対配置しているときに、上下0だけだと、上に張り付こうとするのでmargin:autoを設定することで、均等分配される。

コメント