$(function() {
$('.container').each(function() {
var scaleY = $(this).height() / $('.conteudo', this).height(),
translateY = (($('.conteudo', this).height() - $(this).height()) / 2) * -1;
$('.conteudo', this).css({
'-webkit-transform': 'matrix(1,0,0,' + scaleY + ',0,' + translateY + ')',
'-moz-transform': 'scaleY(1,0,0,' + scaleY + ',0,' + translateY + ')',
'-ms-transform': 'scaleY(1,0,0,' + scaleY + ',0,' + translateY + ')',
'-o-transform': 'scaleY(1,0,0,' + scaleY + ',0,' + translateY + ')',
'transform': 'scaleY(1,0,0,' + scaleY + ',0,' + translateY + ')'
});
});
});
.container {
float: left;
font-size: 100%;
border: 1px solid red;
height: 200px;
width: 200px;
margin-right: 10px
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="conteudo">
Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe
</div>
</div>
<div class="container">
<div class="conteudo">
Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola
Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe Hola Pepe
</div>
</div>
Here’s everything out of the div on your snippet.
– Bacco