html - antd 按钮换行文字

标签 html css antd

使用 antd包 (v3) 我想要一个固定宽度的按钮,在需要时环绕其文本和换行符,以便文本适合按钮内部并且边框正确显示在文本周围。

这是我目前尝试过的:Codepen .我注意到使用 whitespace: normal 适用于但不适用于 antd

const {  Button  } = antd;

ReactDOM.render(
  <>
  <div style={{width:"100px"}}>
    <Button block type="primary" ghost style={{whiteSpace: "normal"}}>Wrap around text</Button>
  </div>
  <button style={{width: '100px', whiteSpace: 'normal'}} type='primary'>Wrap around text</button>
  </>,
  mountNode,
);

最佳答案

"ant-btn" 具有固定的高度属性,您应该需要自动覆盖它并且它可以工作。

<Button block type="primary" ghost style={{whiteSpace: "normal",height:'auto',marginBottom:'10px'}}>Wrap around text</Button>

关于html - antd 按钮换行文字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63393675/

相关文章:

javascript - 无法使用 ant design 和 React 更改多选的值

html - CSS - 悬停可见另一个子菜单

html - 使用 CSS 对齐列

html - 如何在计算机屏幕上模拟灰白色纸张的外观

javascript - 引导问题

javascript - 为什么在 Ant Design 表单中自定义输入控件无法正确验证?

html - 如何使用 ant-design 在布局中拉伸(stretch)父元素宽度

javascript - 检查 div 是否在页面上,如果不在则隐藏按钮

javascript - 组合 "(.*?)"和 "(.*?(\n))+.*?"的正则表达式是什么?

javascript - 根据 Web 浏览器的大小调整对象的大小