2012-08-14 120 views

回答

3

這可能會爲你工作,試試這個

var originalFontSize = 12; 

var divWidth = $('.cell').width(); 

$('.cell span').each(function(){ 

    var spanWidth = $(this).width(); 

    var newFontSize = (divWidth/spanWidth) * originalFontSize; 

    $(this).css({"font-size" : newFontSize, "line-height" : newFontSize/1.2 + "px"}); 

});​ 
+0

正要張貼類似的東西,但你的解決方案更有效。不足之處在於沒有門檻,「veeeeeery looooooong text」變得難以辨認。 – 2012-08-14 10:59:01

+0

非常感謝你的偉大的解決方案 – haynar 2012-08-14 11:39:50

相關問題