两个div之间的分隔线

彼得·皮克

我正在尝试在div /列之间实现分隔线,如下图所示。我已经尝试过使用带有padding和margin的边框,但是这些都不起作用。我想知道实现这一目标的最佳方法是什么?

在此处输入图片说明

小提琴:

http://jsfiddle.net/Lr5d096n/1/

html

<div class="container-col">
    <div></div>
<div class="column-center">
    <div class="top-div">
        <img src="http://static.squarespace.com/static/523ce201e4b0cd883dbb8bbf/t/53bf2302e4b06e125c374401/1405035267633/profile-icon.png"></img>
     </div>
    <div class="bottom-div">
        <h5>headline</h5>
                <div class="game-table">
        <div class="game-item">
            <div class="game-home">home Team</div>
            <div class="game-vs">Vs.</div>
            <div class="game-away">away team</div>
        </div>
        </div>
        Nibh voluptua eleifend sed ne, ex melius maiorum vix, ea case percipit sit. Quo in scripta prodesset, ex nam sonet theophrastus. Read More ...
    </div>

</div>
<div class="column-left">
        <div class="top-div">
        <img src="http://static.squarespace.com/static/523ce201e4b0cd883dbb8bbf/t/53bf2302e4b06e125c374401/1405035267633/profile-icon.png"></img>
    </div>
    <div class="bottom-div">
        <h5>headline</h5>
                <div class="game-table">
        <div class="game-item">
            <div class="game-home">home Team</div>
            <div class="game-vs">Vs.</div>
            <div class="game-away">away team</div>
        </div>
        </div>
        Nibh voluptua eleifend sed ne, ex melius maiorum vix, ea case percipit sit. Quo in scripta prodesset, ex nam sonet theophrastus. Read More ...
    </div>
    </div>
<div class="column-right">

        <div class="top-div">
        <img src="http://static.squarespace.com/static/523ce201e4b0cd883dbb8bbf/t/53bf2302e4b06e125c374401/1405035267633/profile-icon.png"></img>
    </div>
    <div class="bottom-div">
        <h5>headline</h5>
        <div class="game-table">
        <div class="game-item">
            <div class="game-home">home Team</div>
            <div class="game-vs">Vs.</div>
            <div class="game-away">away team</div>
        </div>
        </div>
        Nibh voluptua eleifend sed ne, ex melius maiorum vix, ea case percipit sit. Quo in scripta prodesset, ex nam sonet theophrastus. Read More ...
    </div>
    </div>
</div>

的CSS

.container-col {高度:自动; 显示:表;底边距:20px;}

.column-left{ float: left; width: 33.333%;  height: auto; padding-bottom: 20px; }
.column-right{ float: right; width: 33.333%; height: auto; padding-bottom: 20px; }
.column-center{ display: inline-block; width: 33.333%;  height: auto; padding-bottom: 20px; }

.top-div {

    height: auto;
}

.bottom-div {
  line-height: 18px;
    height:auto;
}

.bottom-div h5 {
    margin-top: 0px;
    margin-bottom: 10px;
    text-align: center;

}

.top-div img {
    width:100%;
    height: auto;
}

.game-table {
border-top: 1px dotted #aaa;
margin-bottom: 10px;
}


.game-item {
    padding: 8px 0px;
    border-bottom: 1px dotted #aaa;
    height: auto;

}

.game-home {
 float: left;
    width: 44%;
    margin-right: 2%;
    text-align: right;
}

.game-vs {
    width: 8%;
    margin-right: 2%;
     display: inline-block;
    text-align: center;

}

.game-away {
    float: right;
   width: 44%;
    text-align: left;

}
大卫说恢复莫妮卡

为了实现这一点,我用border-leftborder-right.center元件,我也整理的共同属性.column-left.column-rightcolumn-center元件一起:

.column-left,
.column-right,
.column-center {
  width: 33.333333%;
  height: auto;
  /* causes the padding, and borders, to be included in the calculated
     width of the elements: */
  box-sizing: border-box;
  /* setting padding for the elements top, right, bottom, left: */
  padding: 0 0.5em 20px 0.5em;
  // setting the border for all elements: */
  border: 1px solid transparent;
}
.column-center {
  display: inline-block;
  /* overriding the transparent colour for the left and right borders: */
  border-left-color: #aaa;
  border-right-color: #aaa;
}

.container-col {
  height: auto;
  display: table;
  margin-bottom: 20px;
}
.column-left,
.column-right,
.column-center {
  width: 33.333333%;
  height: auto;
  box-sizing: border-box;
  padding: 0 0.5em 20px 0.5em;
  border: 1px solid transparent;
}
.column-left {
  float: left;
}
.column-right {
  float: right;
}
.column-center {
  display: inline-block;
  border-left-color: #aaa;
  border-right-color: #aaa;
}
.top-div {
  height: auto;
}
.bottom-div {
  line-height: 18px;
  height: auto;
}
.bottom-div h5 {
  margin-top: 0px;
  margin-bottom: 10px;
  text-align: center;
}
.top-div img {
  width: 100%;
  height: auto;
}
.game-table {
  border-top: 1px dotted #aaa;
  margin-bottom: 10px;
}
.game-item {
  padding: 8px 0px;
  border-bottom: 1px dotted #aaa;
  height: auto;
}
.game-home {
  float: left;
  width: 44%;
  margin-right: 2%;
  text-align: right;
}
.game-vs {
  width: 8%;
  margin-right: 2%;
  display: inline-block;
  text-align: center;
}
.game-away {
  float: right;
  width: 44%;
  text-align: left;
}
<br>
<div class="container-col">
  <div></div>
  <div class="column-center">
    <div class="top-div">
      <img src="http://static.squarespace.com/static/523ce201e4b0cd883dbb8bbf/t/53bf2302e4b06e125c374401/1405035267633/profile-icon.png"></img>
    </div>
    <div class="bottom-div">
      <h5>headline</h5>

      <div class="game-table">
        <div class="game-item">
          <div class="game-home">home Team</div>
          <div class="game-vs">Vs.</div>
          <div class="game-away">away team</div>
        </div>
      </div>Nibh voluptua eleifend sed ne, ex melius maiorum vix, ea case percipit sit. Quo in scripta prodesset, ex nam sonet theophrastus. Read More ...</div>
  </div>
  <div class="column-left">
    <div class="top-div">
      <img src="http://static.squarespace.com/static/523ce201e4b0cd883dbb8bbf/t/53bf2302e4b06e125c374401/1405035267633/profile-icon.png"></img>
    </div>
    <div class="bottom-div">
      <h5>headline</h5>

      <div class="game-table">
        <div class="game-item">
          <div class="game-home">home Team</div>
          <div class="game-vs">Vs.</div>
          <div class="game-away">away team</div>
        </div>
      </div>Nibh voluptua eleifend sed ne, ex melius maiorum vix, ea case percipit sit. Quo in scripta prodesset, ex nam sonet theophrastus. Read More ...</div>
  </div>
  <div class="column-right">
    <div class="top-div">
      <img src="http://static.squarespace.com/static/523ce201e4b0cd883dbb8bbf/t/53bf2302e4b06e125c374401/1405035267633/profile-icon.png"></img>
    </div>
    <div class="bottom-div">
      <h5>headline</h5>

      <div class="game-table">
        <div class="game-item">
          <div class="game-home">home Team</div>
          <div class="game-vs">Vs.</div>
          <div class="game-away">away team</div>
        </div>
      </div>Nibh voluptua eleifend sed ne, ex melius maiorum vix, ea case percipit sit. Quo in scripta prodesset, ex nam sonet theophrastus. Read More ...</div>
  </div>
</div>

参考:

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何在两个文本行android之间绘制垂直分隔线?

来自分类Dev

Android在两个分隔线之间水平对齐TextView

来自分类Dev

如何在两个文本线android之间绘制垂直分隔线?

来自分类Dev

如何使用分隔线调整两个div的大小?

来自分类Dev

如何在两个中间列之间绘制分隔线?

来自分类Dev

两个div之间的hr线

来自分类Dev

两个div之间的hr线

来自分类Dev

PreferenceScreen 之间的分隔线

来自分类Dev

显示元素之间的分隔线

来自分类Dev

PreferenceFragment中类别之间的分隔线

来自分类Dev

如何调整每个菜单项之间的菜单分隔线(文本之间的分隔线)?

来自分类Dev

两个之间用 AND 分隔

来自分类Dev

用CSS替换div线分隔线

来自分类Dev

UIPickerView分隔线

来自分类Dev

uitableviewCell分隔线

来自分类Dev

创建连接两个DIV的线

来自分类Dev

如何填充两个样条线或线之间的区域

来自分类Dev

分隔两个“ div”元素

来自分类Dev

如何删除ActionBar和标签之间的分隔线

来自分类Dev

装饰RecyclerView(使用GridLayoutManager)以显示项目之间的分隔线

来自分类Dev

RadioGroup中RadioButton之间的分隔线-与GMail相似

来自分类Dev

在抽屉清单项目之间添加分隔线

来自分类Dev

在子图之间绘制分隔线或线条

来自分类Dev

行与行之间的分隔线之前/之后的间距

来自分类Dev

警报后备选项之间的分隔线

来自分类Dev

macOS:在NSMenu NSMenuItem之间添加分隔线?

来自分类Dev

在每个ListView项之间添加边框或分隔线

来自分类Dev

Eclipse-Plugin:FieldEditor之间的分隔线可能吗?

来自分类Dev

在水平Sass Suss网格之间添加分隔线