I have the following solution to center my text:
.close-button {
margin-top: auto;
padding: 0;
cursor: pointer;
border: none;
border-radius: 5rem;
background: black;
color: white;
position: relative;
width: 5rem;
height: 5rem;
display: flex;
flex-direction: column;
justify-content: center;
align-content: center;
}
<button class="close-button">
<div class="mark">+</div>
</button>
As you can see, the element is perfectly centered, I believe. However, when I add a big font-size the element containing text appears at random locations. See below:
.close-button {
margin-top: auto;
padding: 0;
cursor: pointer;
border: none;
border-radius: 5rem;
background: black;
color: white;
position: relative;
width: 5rem;
height: 5rem;
display: flex;
flex-direction: column;
justify-content: center;
align-content: center;
/*The line below is new*/
font-size: 8rem;
}
<button class="close-button">
<div class="mark">+</div>
</button>
Why is that and how can I fix that, so that the element is centered again?
Thanks to the answers, I found out that align-items: center;
solves my issue. However, this does not work in Firefox.
Does anybody know why?