0

In my current scenario I have 6 equally spaced blocks 3 by 3 using Bootstrap and col-*-4. These blocks are just slightly styled thumb-nails (still using Bootstrap 3).

In these boxes I have text at the bottom, which I have positioned with:

position: absolute; bottom:0;

As well as this I have an image above which I have positioned within a DIV using:

 height: 400px;
 display: flex;
 justify-content: center;
 align-items: center;

The end result is this

enter image description here

My question is, instead of using a fixed height when using flex, is there a way to center the image within the entire area of the thumbnail, with the text remaining at the bottom.

Could I make the entire thumbnail display:flex?

Added code below

HTML

<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4">
<div class="thumbnail grey mb-30">
    <div class="img-center">
        <img src="img/picto/originals/png/Heart/Newable_Pictogram_CoolGrey_HEART.png" class="img-responsive picto_padding" alt="...">
    </div>

    <div class="caption">
        <h3>Responsibe finance</h3>
        <p>We’re the responsible alternative for those who find High Street bank finance difficult to obtain. </p>
     </div>
</div>
</div>

CSS

.img-center {
height: 350px;
display: flex;
justify-content: center;
align-items: center;
}

 .grey {
    background: #f0f0f0;
}
.thumbnail {
    border: none;
}
.mb-30 {
    margin-bottom: 30px;
}
.thumbnail {
    border: none;
    min-height: 450px;
    position: relative;
}

.caption{
    position:absolute; 
    bottom:0;
}
Abhishek Pandey
  • 13,302
  • 8
  • 38
  • 68
Jesse Luke Orange
  • 1,949
  • 3
  • 29
  • 71

2 Answers2

0

Maybe use this structure..

<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4 grey mb-30">
<div class="thumbnail">
    <div class="img-center">
        <img src="img/picto/originals/png/Heart/Newable_Pictogram_CoolGrey_HEART.png" class="img-responsive picto_padding" alt="...">
    </div>
</div>
<div class="caption">
       <h3>Responsibe finance</h3>
       <p>We’re the responsible alternative for those who find High     Street bank finance difficult to obtain. </p>
</div>
</div>
grinmax
  • 1,835
  • 1
  • 10
  • 13
0

Is there a specific need for the img-center container? Why not just remove img-center and set thumbnail to display flex?

https://jsfiddle.net/bashaen/wbrzfds7/

<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4">
<div class="thumbnail grey mb-30">
<img src="img/picto/originals/png/Heart/Newable_Pictogram_CoolGrey_HEART.png" class="img-responsive picto_padding" alt="...">

    <div class="caption">
        <h3>Responsibe finance</h3>
        <p>We’re the responsible alternative for those who find High Street bank finance difficult to obtain. </p>
     </div>
</div>

.grey {
    background: #f0f0f0;
}
.thumbnail {
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
}
.mb-30 {
    margin-bottom: 30px;
}
.thumbnail {
    border: none;
    min-height: 450px;
    position: relative;
}

.caption{
    position:absolute; 
    bottom:0;
}
Andrew Ice
  • 831
  • 4
  • 16