Flexbox breaks bootstrap responsiveness

I have a row where one column can vary in height, so I don’t know how tall it is. To correctly position the adjacent column, I used nested checkboxes.

This works fine at the main breakpoint, but as soon as I add a flexible block, it breaks the reaction as the columns no longer stack on the mobile device.

What am I supposed to do here? Should I give up flexbox? How else can I reach this interval?

.container{
  margin-top: 60px;
}
 .container{
  border: 1px solid #000;  
}
.row{
  display: flex;
}
.row-center{
  display: flex;
  flex: 1;
}

.outer{
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  border: 1px solid #000;
  width: 100%;
}

.one, .two, .three{
  flex: 0 0 40px;
  border: 1px solid #000;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>


<div class="container">
  <div class="row">
    <div class="col-xs-12 col-sm-6"><img src="http://placehold.it/350x500"></div>
    <div class="col-xs-12 col-sm-6 row-center">
      <div class="outer">
        <div class="one">some text</div>
        <div class="two">some text</div>
        <div class="three">some text</div>
      </div>
    </div>
  </div>
</div>
Run code

jsfiddle mirror: https://jsfiddle.net/y68dnzwy/

+4
source share
2 answers

Maybe this will help you:

.container{
  margin-top: 60px;
}
 .container{
  border: 1px solid #000;  
}
.row{
  display: flex;
}
.row-center{
  display: flex;
  flex: 1;
}

.outer{
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  border: 1px solid #000;
  width: 100%;
}

.one, .two, .three{
  flex: 0 0 40px;
  border: 1px solid #000;
}
/* Added: */
@media screen and (min-width:100px) and (max-width: 980px) {
  .row-center {
    flex: auto;
  }
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
  <div class="row">
    <div class="col-xs-12 col-sm-6"><img src="http://placehold.it/350x500"></div>
    <div class="col-xs-12 col-sm-6 row-center">
      <div class="outer">
        <div class="one">some text</div>
        <div class="two">some text</div>
        <div class="three">some text</div>
      </div>
    </div>
  </div>
</div>
Run code

Demo

+1

3, 4- , ​​ 2 .

- , , , , , , 2 , 2.

   <div class="row row-flex-box">
        <div class="col-xs-6 col-sm-6 col-md-3">
            <div class="thumbnail flex-col-vertical-center">
                <div class="caption"><span>text text text text</span></div>
            </div>
        </div>
        <div class="col-xs-6 col-sm-6  col-md-3">
            <div class="thumbnail flex-col-vertical-center">
                <div class="caption"><span>text text text text text text text text</span></div>
            </div>
        </div>
        <div class="col-xs-6 col-sm-6  col-md-3">
            <div class="thumbnail flex-col-vertical-center">
                <div class="caption"><span>text text text text</span></div>
            </div>
        </div>
        <div class="col-xs-6 col-sm-6  col-md-3">
            <div class="thumbnail homepage-slider-bottom-block-single flex-col-vertical-center">
                <div class="caption"><span>text text text texttext text text texttext text text text</span></div>
            </div>
        </div>
    </div>

Css:

.row-flex-box {
    display: flex; /* make cols same heigh */
    flex-wrap: wrap; /* alows responsive behavior of cols (otherwise cols will never break on mobile)*/
}

.flex-col-vertical-center {
    display: flex; /* specifing display/flex-direction/justifi-content only because i want to have text aligned in the middle of boxes much cleaner than display:table-cell way*/
    flex-direction: column;
    justify-content: center;
    text-align:center;
    height: 100%; /* since cols have bigger height this has effect, also can be ussefull - height: calc(100% - 15px); with 15px bottom margin */
}
0

Source: https://habr.com/ru/post/1628599/


All Articles