如何使两列的起始高度相同



在我的演示中(http://jsfiddle.net/pdexf/864/),第四个元素的起始位置高于第一个元素。我该如何解决?

摘要:

span {
  margin-left: 14px;
  flex: 1 1 auto;
  overflow: 'hidden';
  word-wrap: break-word;
  /* white-space: -moz-pre-wrap !important; */  /* Mozilla, since 1999 */
  white-space: -webkit-pre-wrap; /*Chrome & Safari */
  white-space: -pre-wrap; /* Opera 4-6 */
  white-space: -o-pre-wrap; /* Opera 7 */
  white-space: pre-wrap; /* css-3 */
  word-wrap: break-word; /* Internet Explorer 5.5+ */
  word-break: break-all;
  white-space: normal;
  background-color: yellow;
}
label {
  box-sizing: border-box;
  background: white;
  color: black;
  padding: 10px;
  margin: 10px 10px 20px 10px;
  display: flex;
  border: 1px solid black;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  break-inside: avoid;
}
ul {
  display: inline-flex, flex: 1 1 auto;
  flex-wrap: wrap;
  margin: 10px 0px 0px 10px;
  column-count: 2;
  column-gap: 20px;
}
div {
  height: 130px;
  background-color: lightblue;
  overflow: scroll;
}
li {
  display: inline; /* want labels to display left-to-right */
  background-color: green;
}
<div>
  <ul>
    <li>
      <label>
            <input type="checkbox"/>
            <span > 1-thisisaverrrrrrrrrrrrryyyyyy_long_word_with_no_spaces </span>
          </label>
    </li>
    <li>
      <label>
            <input type="checkbox"/>
            <span> 2-thisisaverrrrrrrrrrrrryyyyyy_long_word_with_no_spaces </span>
          </label>
    </li>
    <li>
      <label>
            <input type="checkbox"/>
            <span> 3-thisisaverrrrrrrrrrrrryyyyyy_long_word_with_no_spaces </span>
          </label>
    </li>
    <li>
      <label>
            <input type="checkbox"/>
            <span> 4-very_short_word </span>
          </label>
    </li>
    <li>
      <label>
            <input type="checkbox"/>
            <span> 5-medium_length_word </span>
          </label>
    </li>
    <li>
      <label>
            <input type="checkbox"/>
            <span> 6-still_no_spaces </span>
          </label>
    </li>
    <li>
      <label>
            <input type="checkbox"/>
            <span> 7-thisisaverrrrrrrrrrrrryyyyyy_long_word_with_no_spaces   </span>
          </label>
    </li>
  </ul>
</div>

span {
  margin-left: 14px;
  flex: 1 1 auto;
  overflow: 'hidden',
  word-wrap: break-word;
   /* white-space: -moz-pre-wrap !important; */  /* Mozilla, since 1999 */
  white-space: -webkit-pre-wrap; /*Chrome & Safari */ 
  white-space: -pre-wrap;      /* Opera 4-6 */
  white-space: -o-pre-wrap;    /* Opera 7 */
  white-space: pre-wrap;       /* css-3 */
  word-wrap: break-word;       /* Internet Explorer 5.5+ */
  word-break: break-all;
  white-space: normal;
  background-color: yellow;
}
label {
  box-sizing: border-box;
  background: white;
  color: black;
  padding: 10px;
  /*margin: 10px 10px 20px 10px;*/
  display: flex;
  border: 1px solid black;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  break-inside: avoid;
}
ul {
  display: inline-flex,
  flex: 1 1 auto;
  flex-wrap: wrap;
  margin: 10px 0px 0px 10px;
  column-count: 2;
  column-gap: 20px;
}
div {
  height: 130px;
  background-color: lightblue;
  overflow: scroll;
}
li {
  display: inline; // want labels to display left-to-right
  background-color: green;
  margin: 20px 10px 10px; // add margin here
}

我不确定应用时的外观,但是我看到了一种与CSS转换列的方法,以使用显示属性使用table-column以及其中的所有内容想要显示:表格。这个示例我看到了使用的桌子行。我敢肯定可以以相同的方式将其应用于您的问题。

CSS就是这样:

.payment-col{
  width:50%;
  position:relative;
  display:table-cell;
  vertical-align:top;
  padding:10px;
  box-sizing: border-box;   
}
.trcontainer{
 display:table-row;
 display:block;
}

html就是这样:

<div class="trcontainer">
     <div class="payment-col" id="paymentinput-col">
         <!-- insert columned items -->
     </div>
</div>

希望这会有所帮助。

最新更新