如何使用JavaScript设置以小写大写字母显示的字体?
要以小写大写字母设置字体,请使用 fontVariant属性。
示例
您可以尝试运行以下代码来设置要使用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 Font Variant</button>
<script>
function display() {
document.getElementById("myID").style.fontFamily = "verdana,sans-serif";
document.getElementById("myID").style.fontVariant = "small-caps";
}
</script>
</body>
</html>热门推荐
10 厨房祝福语简短100句
11 品牌入驻祝福语简短
12 侄儿高考试祝福语简短
13 感谢室友结婚祝福语简短
14 对好友的祝福语简短
15 乔迁祝福语简短精辟句子
16 媳妇生日简短祝福语朋友
17 英文节日祝福语简短唯美
18 周末祝福语简短有内涵