<button class="button">Button</button>
html {
  height: 100%;
}

body {
  height: 100%;
  display: grid;
  place-content: center;
}

.button {
  position: relative;
	padding: 0.5em 1em;
  border: 0;
  border-radius: 0.5em;
  background-color: pink;
	box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.5);
	cursor: pointer;
}

.button:active,
.active {
  top: 2px;
  left: 1px;
	box-shadow: none;
}
const button = document.querySelector('.button');

button.addEventListener('click', () => {
  button.classList.toggle('active');
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.