I have successfully created a styled "a" element that functions as a close button for a modal, redirecting you to the home page when clicked. However, I am facing an issue with vertically centering the "X" within the button. Enclosing it in a "button" element caused further problems. Below is the relevant code:
:root {
--main-color: #ffc40c;
--secondary-color: lightyellow;
--main-red: #d9001d;
--secondary-red: #ff033e;
--dark-color: #444;
--light-color: #fafafa;
}
body {
font-family: "Source Code Pro", monospace;
background-color: var(--light-color);
color: var(--dark-color);
margin-top: 50px;
margin-left: 0;
margin-right: 0;
margin-bottom: 0;
text-shadow: 1px 1px 5px var(--light-color);
}
a {
text-decoration: none;
}
.close-button {
height: 30px;
width: 30px;
background-color: var(--light-color);
color: var(--main-red);
margin-left: 0.5em;
border: 2px solid var(--main-red);
border-radius: 50%;
font-weight: 700;
text-align: center;
}
.close-modal {
position: fixed;
top: 2.8em;
right: 1.7em;
}
<a class="close-button close-modal" href="#!"> X </a>
Does anyone know how to properly achieve vertical centering for this button?