Vertically center-align a figcaption on an image

Viewed 3345

I'm trying to align a figcaption over an image, in a centered way: result desired

So far, I have the following code:

.portfolio-item figcaption{
    position: relative;
    top: -40px;
    left: -20px;
    width: 280px;
    background: rgb(52,152,219);
    color: white;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    padding: 10px 5px 10px 5px;
}

For the following HTML:

<!-- PORTFOLIO IMAGE 1 -->

<div class="portfolio-item">
    <figure>
        <img  src="assets/img/portfolio/folio01.jpg" alt="">
        <figcaption>
                <h5>UI DESIGN</h5>
                <a data-toggle="modal" href="#myModal" >Take a Look</a>
        </figcaption>
    </figure>
</div>

The problem is, to center it, I'm using left: -20px; which is definitely not that responsive. Any idea? Thanks

2 Answers
Related