gpt4 book ai didi

html - 我的文字与我的 div 重叠

转载 作者:行者123 更新时间:2023-11-28 17:07:56 26 4
gpt4 key购买 nike

我需要将文本包装在 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>

最佳答案

你可以使用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;
}
<div class="flex-container">
<span>longlonglonglonglonglonglong</span>
</div>

关于html - 我的文字与我的 div 重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48296290/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com