How do I make the icon in the middle of the button?

Viewed 25

So I'm very new to HTML and when creating a button with an icon using some guides, it ended up looking like this.

The Code is this:

.button {
    border: none;
    font-family: Arial;
    color: #FFFFFF;
    font-size: 20px;
    border-radius: 5px;
    background-color: #5865f2;
    cursor: pointer;
    align-items: center;
}

.button-icon {
    position: relative;
    padding: 10px 10px;
}

.button-text {
    padding: 10px 18px;
}
<a class="button">
    <i class="button-icon material-icons">discord</i>
    <span class="button-text">TheF1ng3r</span>
</a>

1 Answers

I see, you missed the display: flex on your .button selector

.button {
    display: flex;
    .....
    align-items: center;
}

Note:
if you want to use the CSS align-items property you must include display: flex on your CSS code on the same selector.

Related