简体   繁体   English

在固定列宽的 React Bootstrap 布局周围环绕文本

[英]Wrap Text Around Fixed Column Width React Bootstrap Layout

I have created a React Bootstrap Card with four columns as per the grid system layout.我根据网格系统布局创建了一个包含四列的 React Bootstrap Card。 I'm not the greatest at styling or CSS but I would like the text to be wrapped if it is too long- so for instance, in the image below, "BosniaAndHerzegovina" has pushed one of the columns to the bottom of the card, when I really want the text to be wrapped according to the column size.我不是最擅长造型或 CSS 但如果文本太长,我希望将其换行 - 例如,在下图中,“BosniaAndHerzegovina”已将其中一列推到卡片底部,当我真的希望根据列大小包装文本时。

Here is my JSX for the first column:这是第一列的 JSX:

return (
        <Card style={{ width: '25rem' }}>
            <Card.Body>
                <Row>
                    <Col sm='auto'>
                        <Row style={{ marginTop: '5px', marginBottom: '2.5px' }}>
                            {teams[0].name}
                        </Row>
                        <Row style={{ marginTop: '5px', marginBottom: '2.5px' }}>
                            {teams[1].name}
                        </Row>
                        <Row style={{ marginTop: '5px', marginBottom: '2.5px' }}>
                            {teams[2].name}
                        </Row>
                        <Row style={{ marginTop: '5px', marginBottom: '2.5px' }}>
                            {teams[3].name}
                        </Row>
                    </Col>

.
.
. 

How do I get the text to wrap around a fixed column width?如何让文本环绕固定的列宽?

在此处输入图像描述

to break long texts into multiple lines you can use the css property word-break passing break-all :要将长文本分成多行,您可以使用 css 属性word-break传递break-all

word-break: break-all;

 .box { width: 50px; word-break: break-all; }
 <div class="box">myreallylongsentenceshouldbebrokeninmultiplelines</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM