我需要将文字换成div
。但是,如果我使用flex-wrap
,它不会包装文本,并且div的宽度会变大。我只是想把包装好的文字放在中心位置。
.flex-container {
width: 150px;
height: 150px;
display: flex;
justify-content: center;
align-items: center;
background-color: red;
}

<div class="flex-container">
<span>longlonglonglonglonglonglong</span>
</div>
&#13;
答案 0 :(得分:1)
您可以使用word-break: break-all
:
.flex-container {
width: 150px;
height: 150px;
display: flex;
justify-content: center;
align-items: center;
background-color: red;
word-break: break-all;
}
&#13;
<div class="flex-container">
<span>longlonglonglonglonglonglong</span>
</div>
&#13;