如何在按钮中间制作图标?

一个指头

所以我对 HTML 非常陌生,当使用一些指南创建一个带有图标的按钮时,它最终看起来像这样

代码是这样的:

.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>

Ri'zky

我明白了,你错过了display: flex你的.button选择

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

注意:
如果你想使用 CSSalign-items属性,你必须display: flex在同一个选择器的 CSS 代码中包含

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章