JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/jquery-3.2.1.js"></script>
<script src="https://rawgit.com/maciej-gurban/responsive-bootstrap-toolkit/master/dist/bootstrap-toolkit.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="row">
<div class="col-md-4 col-xs-12">
<figure class="overlay">
<img src="https://preview.ibb.co/iFKqGk/base.jpg" alt="cat" class="img-fluid">
<figcaption>Até<br>
50%<br>
</figcaption>
</figure>
</div>
<div class="col-md-4 col-xs-12">
<figure class="overlay">
<img src="https://preview.ibb.co/iFKqGk/base.jpg" alt="cat" class="img-fluid">
<figcaption>Até<br>
30%<br>
</figcaption>
</figure>
</div>
<div class="col-md-4 col-xs-12">
<figure class="overlay">
<img src="https://preview.ibb.co/iFKqGk/base.jpg" alt="cat" class="img-fluid">
<figcaption>Até<br>
15%<br>
</figcaption>
</figure>
</div>
</div>
CSS
figure.overlay {
position: relative;
width: 100%;
z-index: 1;
}
figure.overlay img {width: 100% }
figure.overlay figcaption {
position: absolute;
z-index: 1000;
height: 100%;
width: 100%;
top: 0;
/**optional background overlay**/
background: rgba(255,255,255,0.2);
/**text, adjust all values as desired**/
padding: 44% 2% 0 15%;
font-weight: 700;
color: purple;
/**some fallback value**/
font-size: 16px;
/**responsive size is roughly 3.4% of the device's viewport width**/
font-size: 2.0vw;
}
JavaScript
(function($, document, window, viewport){
function setTextSize() {
if ((viewport.current() == 'xs') || (viewport.current() == 'sm')) {
$("figure.overlay figcaption").css('font-size','7.0vw');
} else {
$("figure.overlay figcaption").css('font-size','2.4vw');
}
}
// Executes once whole document has been loaded
$(document).ready(function() {
console.log('Current breakpoint:', viewport.current());
setTextSize();
});
$(window).resize(
viewport.changed(function(){
console.log('Current breakpoint:', viewport.current());
setTextSize();
})
);
})(jQuery, document, window, ResponsiveBootstrapToolkit);