Reputation: 7166
Is it possible to tell a h1 to size the text so it fills the full 100% width of the element?
Like this.
code:
<h1>FOO</h1>
<h1>BAAR</h1>
Upvotes: 4
Views: 4339
Reputation: 3165
One possible solution with jQuery would be:
var cs=$("#content").width();
$("h1").each(function(){
var hs=$(this).width();
while(hs<cs)
{
$("h1").css("font-size",hs+0.01+"px");
var hs=$(this).width();
}
while(hs>cs)
{
$("h1").css("font-size",hs-0.01+"px");
var hs=$(this).width();
}
})
Upvotes: -1
Reputation:
Try this plugin.
It's great for responsive text.
EDIT:
jQuery("#element1").fitText(1.2, { minFontSize: '20px', maxFontSize: '540px' });
jQuery("#element2").fitText(1.2, { minFontSize: '40px', maxFontSize: '340px' });
Upvotes: 8
Reputation: 7166
I found a plugin called bigtext that works pretty well, will wait for comments though.
https://github.com/zachleat/BigText
Upvotes: 0