html - 如何在 Bootstrap 列布局中的两个 div 之间添加空间?

标签 html css twitter-bootstrap twitter-bootstrap-3

我想在存档 .html 中做这种风格

我希望能够在白色文本区域内书写。

enter image description here

我从这个开始:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">    </script>
</head>


<body>

<div class="container">
  <h1>Hello</h1>
  <p>hi.</p>            
  <div class="row">
    <div class="col-sm-6" style="background-color:yellow;">
      hola
    </div>
    <div class="col-sm-3" style="background-color:pink;">
      adios
    </div>
  </div>
</div>

</body>
</html>

制作:

enter image description here

那么,我怎样才能得到这个?(行之间的分隔符)

enter image description here

最佳答案

简单考虑offset像下面。您总共使用了 9 列网格 (6 + 3),因此您可以添加最多 3 的偏移量,使总数达到 12。

(我将 sm 替换为 xs 以查看简化代码段中的结果)

.row {
 margin-bottom:10px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container">
  <h1>Hello</h1>
  <p>hi.</p>
  <div class="row">
    <div class="col-xs-6" style="background-color:yellow;">
      hola
    </div>
    <div class="col-xs-3 col-xs-offset-3" style="background-color:pink;">
      adios
    </div>
  </div>
  <div class="row">
    <div class="col-xs-6" style="background-color:yellow;">
      hola
    </div>
    <div class="col-xs-3 col-xs-offset-2" style="background-color:pink;">
      adios
    </div>
  </div>
  <div class="row">
    <div class="col-xs-6" style="background-color:yellow;">
      hola
    </div>
    <div class="col-xs-3 col-xs-offset-1" style="background-color:pink;">
      adios
    </div>
  </div>
</div>

关于html - 如何在 Bootstrap 列布局中的两个 div 之间添加空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48754291/

相关文章:

html - Bootstrap 下拉菜单溢出 html 正文

jquery - 无论排序如何,如何获取最后一个表行?

javascript - Bootstrap datetimepicker 小部件中的语言

javascript - 为什么 AngularJS ng-repeat 过滤搜索词不起作用?

html - 使蒙版背景中的列表框可见

javascript - mouseenter + mouseleave/hover 在两个不同的 div 上

css - Sublime Text 2 - SASS 构建 - '[Errno 2] No such file or directory'

html - 在站点两侧创建两个 div 列

jquery - 模态内的 Bootstrap 表单未正确对齐

javascript - 用模糊覆盖两个div