简体   繁体   English

动态更改字体大小以适应内容量

[英]dynamically change font size to accommodate content amount

Lets say I have a box which is 200px X 200px in size.假设我有一个大小为 200px X 200px 的盒子。 And I have a RSS feed item within it.我在其中有一个 RSS 提要项目。

My font size is set by CSS at 17px with a text shadow with a font weight of bold.我的字体大小由 CSS 设置为 17px,带有粗体字重的文本阴影。

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?有没有办法动态改变字体的大小,使整个博客标题可以显示在 200x200 的框中?

PS: I am using asp:repeater control to create the html markup. PS:我正在使用 asp:repeater 控件来创建 html 标记。 So potentially i might be able to write some C#所以我可能会写一些 C#

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/ http://jsfiddle.net/ZprxD/1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM