【问题标题】:Text is overlapping it's P tag文本与它的 P 标签重叠
【发布时间】:2018-12-13 21:46:31
【问题描述】:

我在<p> 标签中有一些文本,但文本没有正确换行,因此超出了父<div> 的宽度。

不确定我是否遗漏了一些以前从未遇到过的非常明显的东西,但我在 sn-p 中重新创建了它。

.row {
  background: #f8f9fa;
  margin-top: 20px;
}

.col {
  border: solid 1px #6c757d;
  padding: 10px;
}

h4 {
  text-align: center;
  color: #0e2753;
}

.btn--vehicle-condition {
  text-align: center;
  width: 100%;
  background-color: #f1f1f1;
  border-radius: 3px;
  padding-top: 15px;
  margin-bottom: 30px;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<!-- 
  Bootstrap docs: https://getbootstrap.com/docs
-->

<div class="container">
  <div class="row">
    <div class="col 12 col-md-6">
      <div class="btn btn--vehicle-condition">
        <h4>
          Preowned
        </h4>
        <p>
          A bit of information about what 'Preowned' means and how it affects the buyer.
        </p>
      </div>
    </div>
    <div class="col 12 col-md-6">
      <div class="btn btn--vehicle-condition">
        <h4>
          New
        </h4>
        <p>
          A bit of information about what 'New' means and how it affects the buyer.
        </p>
      </div>
    </div>
  </div>  
</div>

我查看了其他一些类似的帖子,例如this one,但在他们的情况下,这似乎是因为文本中没有任何空格,而这里不是这种情况。

【问题讨论】:

  • 你有它在 btn 类中,它是 white-space:nowrap,你可以添加一个覆盖:.btn p {white-space:normal} - 小提示右键单击并检查元素,你可以看到所有影响你元素的样式
  • 啊,太好了,就是这样 - 谢谢!

标签: html css bootstrap-4


【解决方案1】:

你需要添加css .btn p {空白:正常}

`https://jsfiddle.net/asimshahiddIT/gpna5fyv/3/`

【讨论】:

    猜你喜欢
    • 2018-11-30
    • 1970-01-01
    • 2018-09-07
    • 2021-02-12
    • 2019-05-11
    • 2021-09-07
    • 2016-08-15
    • 1970-01-01
    • 2020-11-23
    相关资源
    最近更新 更多