<div class="container">
<button class="icon">
<i class="fas fa-wifi"></i>
</button>
<button class="icon">
<i class="fab fa-bluetooth-b"></i>
</button>
<button class="icon">
<i class="fas fa-volume-up"></i>
</button>
<button class="icon">
<i class="fas fa-plane"></i>
</button>
<button class="icon">
<i class="fas fa-map-marker-alt"></i>
</button>
<button class="icon">
<i class="fas fa-gamepad"></i>
</button>
</div>
:root {
--background-color: #000;
--icon-bg: #212121;
--icon-fg: gray;
}
* {
margin: 0;
padding: 0;
}
body {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
background: var(--background-color);
}
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
}
.icon {
all: unset;
font-size: 1.4rem;
width: 40px;
height: 40px;
padding: 0.5rem;
border-radius: 999px;
display: grid;
place-items: center;
background: var(--icon-bg);
color: var(--icon-fg);
border: 2px solid transparent;
transition: background 200ms ease-in-out;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
}
@media screen and (min-width: 500px) {
.icon:hover {
border: 2px solid white;
box-shadow: 0 0 20px -5px white;
}
}
.active-icon {
--icon-bg: white;
--icon-fg: black;
}
const icons = document.querySelectorAll(".icon");
icons.forEach((icon) =>
icon.addEventListener("click", () => {
icon.classList.toggle("active-icon");
})
);
This Pen doesn't use any external CSS resources.