ボタン諸々

単体ボタン
a.sam32 {
display: inline-flex;
background-color: #2196f3;
border-radius: 50%;
height: 50px;
width: 50px;
justify-content: center;
align-items: center;
}
a.sam32::after {
content: "";
display: inline-block;
transform: translateX(-15%) rotate(45deg);
color: #fff;
width: 30%;
height: 30%;
border-top: solid 2px;
border-right: solid 2px;
}
a.sam33 {
position: relative;
display: inline-block;
height: 50px;
width: 50px;
}
a.sam33::before {
content: "";
height: 100%;
width: 100%;
position: absolute;
top: 0;
left: 0;
background: #214bf3;
border-radius: 50%;
}
a.sam33::after {
content: "";
width: 30%;
height: 30%;
display: inline-block;
border-top: solid 2px #fff;
border-right: solid 2px #fff;
position: absolute;
top: 50%;
left: 50%;
z-index: 2;
transform: translate(-68%, -52%) rotate(45deg);
}
a.sam34 {
display: inline-grid;
place-content: center;
background: #c221f3;
width: 50px;
height: 50px;
border-radius: 50%;
}
a.sam34::after {
content: "";
background: #fff;
height: 21px;
width: 14px;
clip-path: polygon(0 10%, 10% 0, 100% 50%, 10% 100%, 0 90%, 70% 50%);
transform: translateX(15%);
}
/* a.34からの変更点
a.sam35 {
background: #79717b;
}
a.sam35::after {
height: 16px;
width: 12px;
clip-path: polygon(0 0, 100% 50%, 0 100%);
}
clip-path アイコン
<p class="triangle"></p>
<p class="triangle right2"></p>
<p class="triangle down"></p>
<p class="triangle left"></p>
<p class="arrows_right"></p>
.sam29 {
.triangle {
background: #333;
height: calc(tan(60deg) * 60px / 2);
width: 60px;
clip-path: polygon(50% 0, 100% 100%, 0 100%);
&.up {
clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
&.right2 {
clip-path: polygon(0 0, 100% 50%, 0 100%);
width: calc(tan(60deg) * 60px / 2);
height: 60px;
}
&.down {
clip-path: polygon(0 0, 100% 0, 50% 100%);
}
&.left2 {
clip-path: polygon(0 50%, 100% 0, 100% 100%);
width: calc(tan(60deg) * 60px / 2);
height: 60px;
}
}
.arrows_right {
background: #c11;
height: 40px;
width: 25px;
clip-path: polygon(0 10%, 10% 0, 100% 50%, 10% 100%, 0 90%, 70% 50%);
}
}
4. borderで×
ハンバーガーメニューには必須
positionを指定しないと×の位置が揃わない
originで指定しても
transformで調整してもなんか揃わないのでposition版で 例)↓
sam39 {
position: relative;
background: #222;
height: 80px;
width: 80px;
border-radius: 50%;
}
.sam39:before,
.sam39:after {
position: absolute;
top: 50%;
left: 50%;
content: "";
width: 50px;
height: 4px;
background: #fff;
}
.sam39:before {
transform: translate(-50%, -50%) rotate(45deg);
}
.sam39:after {
transform: translate(-50%, -50%) rotate(135deg);
}
clip-pathは記述が少ない
太くする場合は
clip-path: polygon(10% 0, 0 10%, 40% 50%, 0 90%, 10% 100%, 50% 60%, 90% 100%, 100% 90%, 60% 50%, 100% 10%, 90% 0, 50% 40%);
.sam40 {
display: inline-grid;
place-content: center;
background: #20a892;
width: 50px;
height: 50px;
border-radius: 50%;
}
.sam40::after {
content: "";
background: #fff;
height: 20px;
width: 20px;
clip-path: polygon(5% 0, 0 4%, 45% 50%, 0 95%, 5% 100%, 50% 55%, 95% 100%, 100% 95%, 55% 50%, 100% 5%, 95% 0, 50% 45%);
}
コピー有
矢印付き
widthは fit-content;で指定
margin-top: -0.1em;はline-height対策
矢印はclip-pathで指定
コピーは span で囲む
複数行対応(max-width要記述)
あのイーハトーヴォの
動きは
@media (any-hover: hover) {
.sam41:hover {
filter: invert();
}
.sam41:hover::after {
transform: translateX(5px);
}
}
.sam41 {
display: grid;
align-items: center;
grid-template-columns: auto 1fr;
width: fit-content;
margin: 0 auto;
column-gap: 1em;
background: #111;
color: #fff;
padding: 1em 1.7em 1em 2.4em;
border-radius: 10vw;
}
.sam41::after {
content: "";
background: #fff;
display: grid;
justify-self: end;
margin-top: -0.1em;
height: 14px;
width: 8px;
clip-path: polygon(0 10%, 10% 0, 100% 50%, 10% 100%, 0 90%, 70% 50%);
}
中丸の場合
widthは fit-content;で指定
あのイーハトーヴォのすきとおった風、 夏でも底に冷たさをもつ
動きは
@media (any-hover: hover) {
.sam42,
.sam42::before,
.sam42::after {
transition: 0.2s all ease-in-out;
}
.sam42:hover {
filter: invert();
border-radius:1em;
}
.sam42:hover:before {
transform: scale(1.3);
opacity: 0.4;
}
.sam42:hover::after {
transform: translateX(6px);
}
}
.sam42 {
display: flex;
align-items: center;
justify-content: center;
width: fit-content;
background: #333;
color: #fff;
font-size: 21px;
font-size: min(2vw, 21px);
padding: 1em 3.5em 1em 2em;
position: relative;
}
.sam42::before {
content: "";
display: inline-block;
background: #fff;
border-radius: 50%;
height: 0.8lh;
width: 0.8lh;
position: absolute;
right: 1.5em;
}
.sam42::after {
content: "";
background: #c33;
height: 12px;
width: 7px;
clip-path: polygon(0 20%, 20% 0, 100% 50%, 20% 100%, 0 80%, 50% 50%);
position: absolute;
right: 1.9em;
}
inset
inset: 0で要素内にボタンを設置
aタグで囲むより事故が少ない
<div class="sam44">
<div class="Card">
<p>あのイーハトーヴォのすきとおった風</p>
<div class="image"></div>
<data>2025.04.06</data>
<a href="#s01"></a>
</div>
<div class="Card">
<p>あのイーハトーヴォの</p>
<data>2025.04.06</data>
<a href="#s02"></a>
</div>
<div class="Card">
<p>あのイーハトーヴォのすきとおった風、夏でも底に冷たさをもつ</p>
<data>2025.04.06</data>
<a href="#s03"></a>
</div>
<div class="Card"><
<p>あのイーハトーヴォのすきとおった風</p>
<data>2025.04.06</data>
<a href="#s04"></a>
</div>
<div class="Card">
<p>
align-self: end;<br />
justify-self: end;
</p>
<data>2025.04.06</data>
<a href="#s05"></a>
</div>
</div>
.sam44 {
display: grid;
gap: 1em;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
& .Card {
display: grid;
background: #f3f3f3;
outline: 2px solid #fff;
filter: drop-shadow(0 0 3px #add);
padding: 1em 2em;
position: relative;
transition: background 0.3s ease-in-out, filter 0.3s 0.5s ease-in-out;
& p {
font-weight: 700;
margin: 0 0 0.5rem;
}
& .image {
aspect-ratio: 16 / 9;
width: 100%;
margin-inline: auto;
background: #555;
}
& data {
align-self: end;
justify-self: end;
font-size: 0.86rem;
margin: 0.5rem 0 0;
}
& a {
position: absolute;
inset: 0;
}
&:has(a:hover) {
background: #83adb5;
filter: drop-shadow(0 0 3px #ccc);
}
}
}