去除容器内的边距

时间:2019-04-19 15:40:04

标签: css bootstrap-4

是否可以删除容器内的边距(也许我使用的术语不正确)? 如果运行代码段,您会看到容器的左侧与文本之间有一段距离。有办法删除它吗?

.container{
  border:1px solid black;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

<div class="container">
  <h2>Hello</h2>
</div>

1 个答案:

答案 0 :(得分:1)

您忘记添加用于处理边距的.row

.container{
  border:1px solid black;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

<div class="container">
  <div class="row">
    <h2>Hello</h2>
  </div>
</div>