I'm doing a function that takes all elements with class="maximize_size" and maximize its content (text) as large as possible inside each element.
I would be happy if I could do this with a css trick, but I didn't found how.
So, I'm trying to do it with javascript/jquery... and I stucked in a point:
$(".maximize_size").each(function(){
var element = $(this);
var content = element.contents();
var raiseContent = $("<div></div>");
content.wrap(raiseContent);
var currentSize = 10;
while (currentSize < 150) {
raiseContent.css({"font-size": currentSize + "px"});
console.log(raiseContent.height() + " : " + element.height());
if (raiseContent.height() > element.height())
break;
currentSize++;
}
element.css({"font-size": currentSize + "px"});
content.unwrap();
});
When I use console.log(raiseContent.height()) it shows always 0 !!!
And for that reason my break-condition inside the while never occurs.
I would be happy if you could give me some direction.
Thanks for your time.