在CSS中,我们可以通过fontsize属性来控制字体的大小。这个属性可以用于所有HTML标签,比如p、h1、h2等等。如果我们要将p标签中的字体放大,可以这样写:p { fontsize: 20px...
在CSS中,我们可以通过font-size属性来控制字体的大小。这个属性可以用于所有HTML标签,比如p、h1、h2等等。
如果我们要将p标签中的字体放大,可以这样写:
p {
font-size: 20px;
} p {
font-size: 150%;
} html {
font-size: 16px;
}
p {
font-size: 1.5rem; // 等同于24px
} function increaseFontSize() {
var p = document.getElementsByTagName("p");
for (var i = 0; i < p.length; i++) {
var fontSize = window.getComputedStyle(p[i], null).getPropertyValue('font-size');
var currentSize = parseFloat(fontSize);
p[i].style.fontSize = (currentSize + 2) + 'px';
}
}