Reputation: 14906
I want to space these 3 divs evenly in a column but their parent (.outer
) won't go to 100% height of the other columns contents. I think because its parent doesn't have a fixed height set.
.container{
margin-top: 60px;
}
.container{
border: 1px solid #000;
}
.outer{
border: 1px solid #000;
}
.row-center{
height: 100%;
}
.outer{
display: flex;
flex-direction: column;
justify-content: space-around;
height: 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"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-xs-6"><img src="http://placehold.it/350x500"></div>
<div class="col-xs-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>
jsfiddle mirror: https://jsfiddle.net/4mxfbody/2/
What is the best procedure here? I have tried absolute positioning .outer
but could not get it to work right.
Upvotes: 2
Views: 2481
Reputation: 115279
Nested flexboxes
* {
margin: 0;
padding: 0;
}
.container {
border: 1px solid #000;
}
.outer {
border: 1px solid #000;
}
.row {
display: flex;
}
.row-center {
display: flex;
flex-direction: column;
}
.outer {
display: flex;
flex-direction: column;
justify-content: space-around;
flex: 1;
}
.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-6">
<img class="img-responsive" src="http://placehold.it/350x500">
</div>
<div class="col-xs-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>
Upvotes: 3