在bootstrap div的行和列的边界

时间:2017-02-23 13:12:53

标签: html css twitter-bootstrap

我创建了一个jsFiddle。我希望边框应该在两个行线之间,但是背景颜色要像它在js小提琴中显示的那样。如何扩展此列边界线。

我的Html

<div class="container top5">
    <div class="row">
        <div class="col-md-12 col-xs-12">
            <div class="row">
                <div class="col-md-3 col-xs-3 inner">
                   <div><b>Type</b></div>
                </div>
                <div class="col-md-3 col-xs-3 inner">
                   <div class=""><b>SMS</b></div>
                </div>
                <div class="col-md-3 col-xs-3 inner">
                   <div class=""><b>Email</b></div>
                </div>
                <div class="col-md-3 col-xs-3 inner-end">
                    <div class=""><b>Business Unit</b></div>
                </div>
            </div>
        </div>
        <div class="col-md-12 col-xs-12">
            <div class="row border-between">
                <div class="col-md-3 col-xs-3 inner">
                    <span>Another tesing text</span>
                </div>
                <div class="col-md-3 col-xs-3 inner">
                    <span> test</span>
                </div>
                <div class="col-md-3 col-xs-3 inner">
                    <span>Random text</span>
                </div>
                <div class="col-md-3 col-xs-3 inner-end">
                    <span>Random text</span>
                </div>
            </div>
        </div>
    </div>
</div>

和Css

.top5 {
    margin-top: 50px;
}

.row {
    border: 1px solid;
}

.row + .row {
    border-top:0 ;
}

我的小提琴 - https://jsfiddle.net/ff49tu79/13/

1 个答案:

答案 0 :(得分:2)

您可能希望在单元格中使用填充而不是边距,并使用弹性框将div单元拼接在一起

&#13;
&#13;
.top5 {
  margin-top: 50px;
}

.row {
  border: 1px solid;
}

.row + .row {
  border-top: 0;
}

.flx {
  display: flex;
}

.inner {
  background: aliceblue;
  border-right: 1px solid blue;
  padding: 10px 15px;
}

.inner-end {
  background: aliceblue;
  padding: 10px 15px;
}
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container top5">
  <div class="row">
    <div class="col-md-12 col-xs-12">
      <div class="row">
        <div class="flx">


          <div class="col-md-3 col-xs-3 inner">
            <div><b>Type</b></div>
          </div>
          <div class="col-md-3 col-xs-3 inner">
            <div class=""><b>SMS</b></div>
          </div>
          <div class="col-md-3 col-xs-3 inner">
            <div class=""><b>Email</b></div>
          </div>
          <div class="col-md-3 col-xs-3 inner-end">
            <div class=""><b>Business Unit</b></div>
          </div>
        </div>
      </div>
    </div>
    <div class="col-md-12 col-xs-12">
      <div class="row border-between">
        <div class="flx">
          <div class="col-md-3 col-xs-3 inner">
            <span>Another tesing text</span>
            <div>1</div>
            <div>2</div>
          </div>
          <div class="col-md-3 col-xs-3 inner">
            <span> test</span>
          </div>
          <div class="col-md-3 col-xs-3 inner">
            <span>Random text</span>
          </div>
          <div class="col-md-3 col-xs-3 inner-end">
            <span>Random text</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
&#13;
&#13;
&#13;

See JSFIDDLE