admin管理员组文章数量:1391987
I am using this code to dynamically resize text:
function fontResize(){
$('.features').css('font-size', ($(window).width()/100) + 'px');
}
fontResize();
$(window).resize( function () {fontResize()});
This works great for pulling the browser inwards but when i'm stretching the screen out on my 21" iMac, the text is too big for a set size DIV i have. how can i implement a solution whereby i can cap the maximum font size on the text. Will i be able to override this function above and put a max-font-size of 13px?
Thanks
I am using this code to dynamically resize text:
function fontResize(){
$('.features').css('font-size', ($(window).width()/100) + 'px');
}
fontResize();
$(window).resize( function () {fontResize()});
This works great for pulling the browser inwards but when i'm stretching the screen out on my 21" iMac, the text is too big for a set size DIV i have. how can i implement a solution whereby i can cap the maximum font size on the text. Will i be able to override this function above and put a max-font-size of 13px?
Thanks
Share Improve this question edited Jul 30, 2013 at 18:19 benhowdle89 asked Jul 14, 2011 at 22:14 benhowdle89benhowdle89 37.5k74 gold badges207 silver badges340 bronze badges2 Answers
Reset to default 4function fontResize(){
var size = $(window).width()/100;
if ( size < 13 )
$('.features').css('font-size', size + 'px');
}
You could implement a sizeRange to define maximum and minimum font sizes.
function fontResize(){
var sizeRange = [6, 13];
var size = $(window).width()/100;
if ( size <= sizeRange[1] && size >= sizeRange[0] ) {
$('.features').css('font-size', size + 'px');
} else {
// font-size out of range
}
}
本文标签: Implement a maxfontsize style rule with CSSjavascriptjqueryStack Overflow
版权声明:本文标题:Implement a max-font-size style rule with CSSjavascriptjquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744589290a2614387.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论