【问题标题】:Aligning to the bottom in flexboxflexbox底部对齐
【发布时间】:2016-12-03 01:17:22
【问题描述】:

我的容器应该根据内容动态改变高度。对于给定行中的所有容器,无论每个容器中的内容如何,​​底部文本都应固定在底部。

.flex-list {
  display: flex;
  flex-direction: column;
}
.flex-list .flex-row {
  display: flex;
  margin-bottom: 20px;
}
.flex-list .flex-row .flex-item-wrapper {
  margin-right: 20px;
  width: 100%;
  background-color: yellow;
}
.flex-list .flex-row .flex-item-wrapper:last-child {
  margin-right: 0px;
  background-color: transparent;
}
.flex-list .flex-row .flex-item-wrapper .flex-item {
  width: 100%;
  height: 100%;
}
.flex-item-stats {
  display: flex;
  justify-content: space-between;
  color: grey;
  padding-top: 10px;
}
.flex-item-stats > * {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.caption {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
<div class="profile-content flex-list">
  <div class="flex-row">
    <div class="flex-item-wrapper">
      <div class="flex-item thumbnail clickable" data-href="#">
        <img class="img-circle" src="http://blog.blogcatalog.com/wp-content/uploads/mario-300x300.jpg" style="width:150px">
        <div class="caption">
          <h4>
                <a href="#">Y-find</a>
              </h4>
          <div class="flex-item-stats">
            <small>left</small>
            <small>right</small>
          </div>
        </div>
      </div>
    </div>
    <div class="flex-item-wrapper">
      <div class="flex-item thumbnail clickable" data-href="#">
        <img class="img-circle" src="http://blog.blogcatalog.com/wp-content/uploads/mario-300x300.jpg" style="width:150px">
        <div class="caption">
          <h4>
                <a href="#">Cardguard Namfix</a>
              </h4>
          <div class="flex-item-stats">
            <small>left</small>
            <small>right</small>
          </div>
        </div>
      </div>
    </div>
    <div class="flex-item-wrapper">
      <div class="flex-item thumbnail clickable" data-href="#">
        <img class="img-circle" src="http://blog.blogcatalog.com/wp-content/uploads/mario-300x300.jpg" style="width:150px">
        <div class="caption">
          <h4>
                <a href="#">Voyatouch Voyatouch Voyatouch Voyatouch Voyatouch Voyatouch </a>
              </h4>
          <div class="flex-item-stats">
            <small>left</small>
            <small>right</small>
          </div>
        </div>
      </div>
    </div>
    <div class="flex-item-wrapper">
    </div>
  </div>

</div>

我认为在.caption 上使用display:flexspace-between 可以将flex-item-stats 推到底部,但它似乎没有任何作用。

jsfiddle

【问题讨论】:

标签: html css flexbox


【解决方案1】:

【讨论】:

    【解决方案2】:

    如果您将.caption 代码更改为:

    .caption {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
    }
    

    然后添加:

    .flex-item {
      display: flex;
      flex-direction: column;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-24
      • 2018-01-24
      • 1970-01-01
      • 2018-09-24
      • 2014-09-02
      • 2015-09-09
      • 1970-01-01
      相关资源
      最近更新 更多