-2

如何使文本更大或 div 内的文本?

我真的不知道,帮帮我

就像是:

$('div.text'), { FontSize: '40px' }); // <--- this is not real code, just to show what i need
4

6 回答 6

6
document.getElementById("node1").style.fontSize = "40px";
于 2012-06-01T11:54:40.287 回答
4
$('.text').css('font-size','40px');
于 2012-06-01T11:59:37.727 回答
3

在 jQuery 中,您将这样做的方式是更改 div 的 CSS。这是一个快速的肮脏演示:http: //jsfiddle.net/wjAqm/

实际代码是$("#demo").css("font-size", "20px");

于 2012-06-01T11:58:49.653 回答
1

css如果您有可用的 jQuery,请使用函数。这是一个工作示例 - http://jsfiddle.net/Pharaon/qLuBs/

$('#content').click(function() {
    $(this).css('fontSize', '40px');
});
于 2012-06-01T11:58:05.227 回答
1

试试这个:

$('#div1').css('fontSize', '20px'); 
于 2012-06-01T11:58:27.567 回答
1

小变焦演示:

<button id="bigger">Zoom In</button><button id="smaller">Zoom Out</button>
<div id="text" style="font-size: 1em;">Hello, world.</div>

​&lt;script>

$('#bigger').click( function() { zoom( 1.2 ); } );
$('#smaller').click( function() { zoom( 0.8 ); } );

function zoom( factor ) {
    var div = $('#text');
    var size = div.css( 'font-size' );
    size = parseFloat( size );
    console.log([ 'size', size ]);
    size *= factor;
    div.css( 'font-size', size + 'px' )
}
​&lt;/script>

需要 jQuery 1.7.x。jfiddle 上的现场演示

于 2012-06-01T12:02:40.093 回答