使用 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/