<!DOCTYPE html>
<html>
<head>
<style>
div::first-letter {
font-size: xx-large;
}
</style>
</head>
<body>
<p>单击该按钮以获取测试 div 中第一个字母的计算字体大小。</p>
<p><button onclick="myFunction()">试一试</button></p>
<div id="test" style="height: 50px;background-color: lightblue;">Test Div</div>
<p>测试 div 中 div::first-letter 的计算字体大小为:<span id="demo"></span></p>
<script>
function myFunction(){
var elem = document.getElementById("test");
var theCSSprop = window.getComputedStyle(elem, ":first-letter").getPropertyValue("font-size");
document.getElementById("demo").innerHTML = theCSSprop;
}
</script>
</body>
</html>