调整窗口大小时会展开的字体大小 [英] Font-size that expands when you resize the window
本文介绍了调整窗口大小时会展开的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在HTML中制作我的字体,这样当我展开窗口时,文本的大小也会扩展。类似的设置一个百分比的文本,将占据它的框的大小的百分比。
How do I make my font in HTML such that when I expand the window, the size of the text expands also. Sort of like setting a percentage for the text that will take on a percentage of the size of the box it is in.
这里是一个插图我想要的发生:
Here is an illustration of what I would like to happen:
#box #text {
font-size: 50%;
}
现在让说 #box
为200像素, #text
应为100像素。
显然,我不能只为 #text
设置一个修正宽度,因为在 #box
是一个动态宽度。
Now lets say #box
is 200px, #text
should be 100px.
Obviously I can't just put a fix width for #text
because in the site #box
will be a dynamic width.
推荐答案
在jquery中执行。
Do it in jquery.
$(window).resize(function(){
$('#box #text').css('font-size',($(window).width()*0.5)+'px');
});
这篇关于调整窗口大小时会展开的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文