💎
UIデザイン実装便利帳〜アイコン編 No1 CSSで作るダイヤモンドアイコン
No1 CSSで作るダイヤモンドアイコン
HTML
html
<div class="diamond">
<span></span>
<span></span>
<span></span>
<span></span>
</div>
CSS
css
body{
margin: 0;
padding: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.diamond {
position: relative;
width: 200px;
height: 200px;
transform: rotate(45deg);
}
span:nth-child(1) {
position: absolute;
top: 0;
left: 0;
width: 0;
height: 0;
border-top: 50px solid transparent;
border-right: 50px solid #46a9d9;
border-bottom: 50px solid #5fb6df;
border-left: 50px solid transparent;
}
span:nth-child(2) {
position: absolute;
top: 0;
left: 50%;
width: 0;
height: 0;
border-top: 50px solid #479ec9;
border-right: 50px solid #46a9d9;
border-bottom: 50px solid #5fb6df;
border-left: 50px solid #76c3e1;
}
span:nth-child(3) {
position: absolute;
top: 50%;
left: 0;
width: 0;
height: 0;
border-top: 50px solid #479ec9;
border-right: 50px solid #46a9d9;
border-bottom: 50px solid #5fb6df;
border-left: 50px solid #76c3e1;
}
span:nth-child(4) {
position: absolute;
top: 50%;
left: 50%;
width: 0;
height: 0;
border-top: 50px solid #479ec9;
border-right: 50px solid #46a9d9;
border-bottom: 50px solid #5fb6df;
border-left: 50px solid #76c3e1;
}
Discussion