Bootstrap 3:缺少排水沟

bco*_*713 32 html css twitter-bootstrap twitter-bootstrap-3

刚刚开始使用bootstrap 3,我不能让列之间的排水沟工作.

我创建了最基本的代码来测试:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Test</title>
    <script src="http://code.jquery.com/jquery.js"></script>
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/js/bootstrap.min.js">                                                                                                                                  </script>
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css" rel="stylesheet" media="screen" />
    <style>
        .box1 {
            background-color: green;
        }
        .box2 {
            background-color: blue;
        }
    </style>
</head>
<div class="container">
    <div class="row">
        <div class="col-lg-4 box1">
            <h1>Test</h1>
        </div>
        <div class="col-lg-8 box2">
            <h1>Test2</h1>
        </div>
    </div>
</div>
</html>
Run Code Online (Sandbox Code Playgroud)

结果只有一个绿色/蓝色的大盒子,两个柱子之间没有任何装订线.我也试过一个没有运气的小提琴http://jsfiddle.net/Tgkkb/ 我错过了什么?

Jon*_*ski 62

Bootstrap 3切换到padding用于排水沟而不是margins.所以,内容是分开的,但框不是.一个background-color意志也将填补padding.

但是,您应该可以通过在内框上设置背景来获得所需的效果:

<div class="row">
    <div class="col-sm-4">
        <div class="box1">
            <h1>Test</h1>
        </div>
    </div>
    <div class="col-sm-8">
        <div class="box2">
            <h1>Test2</h1>
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/PFxUk/


尽管如此,我们的目标只是将它应用于background 一个包裹着的孩子.所以,如果标题肯定不会有任何兄弟姐妹,那么你可以放弃额外的<div>s:

<div class="row">
    <div class="col-sm-4">
        <h1 class="box1">Test</h1>
    </div>
    <div class="col-sm-8">
        <h1 class="box2">Test2</h1>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/G2gbG/

  • 你是一个节省生命的人...作为一个相当有经验的开发人员,我几个小时都对此感到沮丧......呃......你有可能在文档中知道它在哪里吗?到目前为止他们似乎很糟糕.再次感谢. (3认同)
  • @ bcoop713我还没有看到3.0文档中的变化 - 它们有点像"*忘记Bootstrap 2*"的语气.但是,它在[Bootstrap 3 Pull Request](https://github.com/twbs/bootstrap/pull/6342)中提到(链接在[发布公告]中(http://blog.getbootstrap.com/2013)/07/27/bootstrap-3-rc1 /))在"网格系统"下使用"新单网格系统". (3认同)