我的问题是 antd 按钮中的文本和图标在我的 React 应用程序中没有垂直对齐。
这是代码:
<Button type="primary" size="large" block icon={<PlusCircleOutlined />} onClick={()=>this.showModalSharePicture()}>
Text
</Button>
与位于按钮中心的文本相比,图标有点低。 如何解决我所有按钮中都存在的这个问题?
这是渲染的 html:
<button type="button" class="ant-btn ant-btn-primary ant-btn-lg ant-btn-block"><span role="img" aria-label="plus-circle" class="anticon anticon-plus-circle"><svg viewBox="64 64 896 896" focusable="false" data-icon="plus-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z"></path><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"></path></svg></span><span>Text</span></button>
最佳答案
一种可能的方法是使用以下样式:
button,
span {
display: inline-flex;
align-items: center;
}
您还可以使用它们的类名 ant-btn
、anticon
根据您的喜好和需求来设置它们的样式。
关于javascript - antd 按钮中的文本和图标未垂直对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71001226/