在下面的代码中,如果您删除文档类型,脚本不会执行它所执行的操作(即,它不会增加文本大小)。 如何转换 fontSize 做作来修复它?
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, height=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0" />
<style>
#hello {
font-family: "AvenirNextCondensed-Bold";
font-size: 12pt;
}
</style>
</header>
<body>
<div id="hello">
Hello
</div>
<script>
document.getElementById("hello").style.fontSize = 50;
</script>
</body>
</html>
最佳答案
要保留 !doctype
,您可以将 js 更改为:
document.getElementById("hello").style.fontSize = "50px";
:)
关于javascript - 如何翻译 style.fontSize = html5 文档的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21923117/