テキストを大きくしたり、div内のテキストを大きくしたりするにはどうすればよいですか?
私は本当に知りません、みんなを助けてください
何かのようなもの:
$('div.text'), { FontSize: '40px' }); // <--- this is not real code, just to show what i need
テキストを大きくしたり、div内のテキストを大きくしたりするにはどうすればよいですか?
私は本当に知りません、みんなを助けてください
何かのようなもの:
$('div.text'), { FontSize: '40px' }); // <--- this is not real code, just to show what i need
document.getElementById("node1").style.fontSize = "40px";
$('.text').css('font-size','40px');
jQuery でこれを行う方法は、div の CSS を変更することです。これは簡単な汚いデモです: http://jsfiddle.net/wjAqm/
実際のコードは$("#demo").css("font-size", "20px");
css
jQuery が利用できる場合は関数を使用します。これが実際の例です - http://jsfiddle.net/Pharaon/qLuBs/
$('#content').click(function() {
$(this).css('fontSize', '40px');
});
これを試して:
$('#div1').css('fontSize', '20px');
リトル ズーム デモ:
<button id="bigger">Zoom In</button><button id="smaller">Zoom Out</button>
<div id="text" style="font-size: 1em;">Hello, world.</div>
<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' )
}
</script>
jQuery 1.7.x が必要です。jfiddle でのライブ デモ。