简体   繁体   English

列出下面的div元素

[英]List div elements underneath each other

How would I get Items 1-4 line up directly underneath each other? 我将如何使1-4项在彼此的正下方对齐?

.remove-top-border {
  border-top: none;
}

.remove-bottom-border {
  border-bottom: none;
}

.remove-top-padding {
  padding-top: 0px;
}

<div class="list">

  <div class="item item-input-inset remove-bottom-border">
    <div class="row">
      <div class="col bold">Cost</div>
    </div>
  </div>

  <div class="item item-input-inset remove-top-border remove-top-padding">
    <div class="col col-75">Item 1</div>
    <div class="col col-25">£20</div>
    <div class="col col-75">Item 2</div>
    <div class="col col-25">£20</div>
    <div class="col col-75">Item 3</div>
    <div class="col col-25">£20</div>
    <div class="col col-75">Item 4</div>
    <div class="col col-25">£20</div>
  </div>

</div>

Output 输出量

The code above returns this at the moment. 上面的代码目前返回此代码。

在此处输入图片说明

Here is my jsfiddle: http://jsfiddle.net/39nszmww/2/ . 这是我的jsfiddle: http : //jsfiddle.net/39nszmww/2/

You are not using the col class properly. 您没有正确使用col类。 The Ionic grid system is based up on the CSS3 flexbox. 离子网格系统基于CSS3 flexbox。 The col class divides into percents, which should sum up to 100 percents. col类分为百分比,总计应为100%。 So you can split your row into as many cols as you wish as long as they don't exceed 100 (otherwise, the grid will bug out as happened to you). 因此,您可以将分成任意数量的 ,只要不超过100个列即可(否则,网格会在您遇到的情况下出错)。

So <div class="col col-50"> will create a column that takes 50% of the row's width. 因此, <div class="col col-50">将创建一列,占该行宽度的50%。

To fix your issue, split each item into a separate row. 要解决您的问题,请将每个项目分成单独的一行。 Also, remove the item-input-inset class because it stops the grid from expanding vertically. 另外,删除item-input-inset类,因为它会阻止网格垂直扩展。

<div class="item">
    <div class="row">
        <div class="col col-75">Item 1</div>
        <div class="col col-25">£20</div>
    </div>
    <div class="row">
        <div class="col col-75">Item 2</div>
        <div class="col col-25">£10</div>
    </div>
    <div class="row">
        <div class="col col-75">Item 3</div>
        <div class="col col-25">£30</div>
    </div>
</div>

JSFiddle: http://jsfiddle.net/0tcdr9dg/ JSFiddle: http : //jsfiddle.net/0tcdr9dg/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM