javascript - antd 按钮中的文本和图标未垂直对齐

标签 javascript css reactjs antd

我的问题是 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-btnanticon 根据您的喜好和需求来设置它们的样式。

关于javascript - antd 按钮中的文本和图标未垂直对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71001226/

相关文章:

javascript - jQuery 输入参数未定义

javascript - jQuery 中的切换功能

html - td 宽度,不起作用?

html - 我怎样才能使文本居中,因为它出现在 border-right 的边缘

html - CSS Sizing - 将子尺寸限制为父尺寸

javascript - 如何将 React Context 中的值传递给 Redux-Saga 函数?

javascript - 来自 GetLocations() 的回调(来自 Google Maps API)可以调用 API 函数以外的任何东西吗?

javascript - 自动登录用户到外部网站?

javascript - React 中的无状态组件和 "Props is defined but never used"ESLint 错误

javascript - Next.js:匹配根 '/' 和动态路由 '/param' 的页面