【问题标题】:My text overlaps my div我的文字与我的 div 重叠
【发布时间】:2018-01-17 08:06:58
【问题描述】:

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

【问题讨论】:

    标签: html css scss-lint


    【解决方案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;
    }
    <div class="flex-container">
      <span>longlonglonglonglonglonglong</span>
    </div>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多