表示デモ
実装コード
HTML
<div class="demo-wrap">
<button class="btn basic color_change trans-y_change radius-s">Button Sample</button>
</div>
CSS
@charset "utf-8";
/* サイト共通設定 */
:root{
--primary-color: #03588C;
--primaty-opacity-color: 0.8;
}
html{
font-size: 62.5%;
}
.demo-wrap {
display: flex;
justify-content: center;
padding: 50px;
}
/* ボタン共通設定 */
.btn {
display:inline-block;
padding: 12px 30px;
font-weight: 600;
line-height: 1.3;
cursor: pointer;
border: 0;
font-size: 1.6rem;
text-decoration: none;
color: #ffffff;
transition: all .25s ease;
-webkit-tap-highlight-color: transparent;
}
.basic {
background: var(--primary-color);
}.width-100 {
width: 100px;
}
.height-100 {
height: 100px;
}
.radius-50p {
border-radius: 50%;
}
/* 変化 */
.color_change:hover, .color_change:focus {
background: var(--primary-accent-color);
}
.trans-y_change:hover, .trans-y_change:focus {
transform: translateY(-3px);
box-shadow: 0 6px 18px rgba(43,140,255,0.12);
}
ポイント
角を丸くする<border-radius>を50%にすることで正円を作る。
幅と高さが指定されていない・幅と高さが異なる値と楕円形になる点に注意。