我認爲這是你想要什麼:
演示:http://jsfiddle.net/SO_AMK/JjutY/
HTML:
<div class="div1">
<div class="div2">
Some text, and more, and more, and more, and more, and more, and more, and more, and more.
</div>
<div class="div3">
Some text, and more, and more, and more, and more, and more, and more, and more, and more.
</div>
<button class="increaseFontSize">Increase Font Size</button>
</div>
jQuery的:
$(".increaseFontSize").click(function(){
var fontSize = getFontSize($(".div3"));
var newFontSize = fontSize + 2;
$(".div3").css("font-size", newFontSize);
return false;
});
function getFontSize(element) {
var currentSize = $(element).css("font-size");
var currentSizeNumber = parseFloat(currentSize);
return currentSizeNumber;
}
是JavaScript的一個選項,或者是你想只用CSS來實現這一目標? – Borophyll 2012-07-11 02:36:42
@Borophyll:當然。我不明白爲什麼不。剛編輯我的問題。 – Legend 2012-07-11 02:37:48