Flexbox - 响应性缩小

时间:2018-04-29 15:41:26

标签: css css3 flexbox

我有一个看起来像这样的flexbox布局。

#flexcanvas{
  width: 100%;
  height: 600px !important;
}

.rowParent, .columnParent{
  display: -webkit-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-box-direction: normal;
  -webkit-box-orient: horizontal;
  -webkit-flex-direction: row;
  -ms-flex-direction: row;
  flex-direction: row;
  -webkit-flex-wrap: nowrap;
  -ms-flex-wrap: nowrap;
  flex-wrap: nowrap;
  -webkit-box-pack: start;
  -webkit-justify-content: flex-start;
  -ms-flex-pack: start;
  justify-content: flex-start;
  -webkit-align-content: stretch;
  -ms-flex-line-pack: stretch;
  align-content: stretch;
  -webkit-box-align: stretch;
  -webkit-align-items: stretch;
  -ms-flex-align: stretch;
  align-items: stretch;
}

.columnParent{
  -webkit-box-orient: vertical;
  -webkit-flex-direction: column;
  -ms-flex-direction: column;
  flex-direction: column;
}

.flexChild{
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  -ms-flex: 1;
  flex: 1;
  -webkit-align-self: auto;
  -ms-flex-item-align: auto;
  align-self: auto;
}


#rowChild96155{
 -webkit-box-flex: 0;
 -webkit-flex: 0 0 auto;
 -ms-flex: 0 0 auto;
 flex: 0 0 auto; width: 410px;
 background:red;
}


#rowChild75422{
 -webkit-box-flex: 0;
 -webkit-flex: 0 0 auto;
 -ms-flex: 0 0 auto;
 flex: 0 0 auto; width: 284px;
 background:blue;
}


#rowChild17121{
 -webkit-box-flex: 0;
 -webkit-flex: 0 0 auto;
 -ms-flex: 0 0 auto;
 flex: 0 0 auto; width: 364px;
 background:yellow;
}


#rowChild17163{
 -webkit-box-flex: 0;
 -webkit-flex: 0 0 auto;
 -ms-flex: 0 0 auto;
 flex: 0 0 auto; width: 488px;
 background:purple;
}


#columnChild92141{
 -webkit-box-flex: 0;
 -webkit-flex: 0 0 auto;
 -ms-flex: 0 0 auto;
 flex: 0 0 auto; height: 295px;
 background:teal;
}


#columnChild85578{
 -webkit-box-flex: 0;
 -webkit-flex: 0 0 auto;
 -ms-flex: 0 0 auto;
 flex: 0 0 auto; height: 385px;
 background:gold;
}


#rowChild30411{
 -webkit-box-flex: 0;
 -webkit-flex: 0 0 auto;
 -ms-flex: 0 0 auto;
 flex: 0 0 auto; width: 360px;
 background:grey;
}
<div id="container" class="flexChild rowParent">
  
  <div id="rowChild30411" class="flexChild columnParent">
    <div id="columnChild85578" class="flexChild"><img src="https://dummyimage.com/360x384/000/fff"></div>

    <div id="columnChild42997" class="flexChild"><img src="https://dummyimage.com/360x181/000/fff"></div>
</div>

  <div id="rowChild2251" class="flexChild columnParent">
    <div id="columnChild92141" class="flexChild rowParent">
      <div id="rowChild17163" class="flexChild"><img src="https://dummyimage.com/488x295/000/fff"></div>

      <div id="rowChild75422" class="flexChild"><img src="https://dummyimage.com/282x295/000/fff"></div>
</div>

    <div id="columnChild7857" class="flexChild rowParent">
      <div id="rowChild17121" class="flexChild selected"><img src="https://dummyimage.com/362x271/000/fff"></div>

      <div id="rowChild96155" class="flexChild"><img src="https://dummyimage.com/408x271/000/fff"></div>
</div>
</div>
</div>

这种布局运行良好,但我希望它能够缩小责任,并保持布局宽高比。

在这种情况下,flexbox是最好用的吗?我需要将宽度转换为百分比吗?

0 个答案:

没有答案