如何在按钮中间制作图标?
How do I make the icon in the middle of the button?
所以我是 HTML 的新手,当使用一些指南创建带有图标的按钮时,它最终看起来像 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>
我明白了,您错过了 .button
选择器上的 display: flex
.button {
display: flex;
.....
align-items: center;
}
注:
如果您想使用 CSS align-items
属性,您必须在同一选择器的 CSS 代码中包含 display: flex
。
所以我是 HTML 的新手,当使用一些指南创建带有图标的按钮时,它最终看起来像 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>
我明白了,您错过了 .button
选择器上的 display: flex
.button {
display: flex;
.....
align-items: center;
}
注:
如果您想使用 CSS align-items
属性,您必须在同一选择器的 CSS 代码中包含 display: flex
。