Search code examples
javascriptjqueryasp.netrssrepeater

dynamically change font size to accommodate content amount


Lets say I have a box which is 200px X 200px in size. And I have a RSS feed item within it.

My font size is set by CSS at 17px with a text shadow with a font weight of bold.

Is there a way to dynamically change the size of the font so that the whole blog title can be displayed in the 200x200 box?

PS: I am using asp:repeater control to create the html markup. So potentially i might be able to write some C#


Solution

  • you could do something crazy like that:

    while ($('div').scrollTop() == 0) {
        $('div').css({'font-size': '+=1'}).scrollTop(100);
    }
    $('div').css({'font-size': '-=1'});​
    

    :)

    demo
    http://jsfiddle.net/ZprxD/1/