如何用JavaScript设置字体的样式是普通,斜体还是斜角?
若要设置字体的样式,请使用fontStyle属性。您可以尝试运行以下代码,以使用JavaScript将字体的样式设置为正常,斜体或倾斜-
示例
<!DOCTYPE html>
<html>
<body>
<h1>Heading 1</h1>
<p id="myID">
This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text.
This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text.
</p>
<button type="button" onclick="display()">Set Font Family and Style</button>
<script>
function display() {
document.getElementById("myID").style.fontFamily = "verdana,sans-serif";
document.getElementById("myID").style.fontStyle = "italic";
}
</script>
</body>
</html>热门推荐
7 留学生祝福语简短
8 火把节祝福语简短
10 幼儿祝福语大全简短贺卡
11 饭店国庆祝福语简短
12 幽默的新娘祝福语简短
13 牛年企业祝福语简短大气
14 简短搞笑蛋糕生日祝福语
15 生日祝福语简短霸气男
16 朝鲜元旦祝福语大全简短
17 兔年简短祝福语8字
18 送教授贺卡祝福语简短