CSS :first-letter 伪元素
cssweb developmentfront end technology更新于 2025/3/18 10:52:17
使用此元素为选择器中文本的首字母添加特殊样式。以下示例演示了如何使用 :first-letter 元素为文档中元素的首字母添加特殊效果。
示例
<html>
<head>
<style>
p:first-letter {
font-size: 5em;
}
p.normal:first-letter {
font-size: 10px;
}
</style>
</head>
<body>
<p class="normal"> First character of this paragraph will be normal and will
have font size 10 px;
</p>
<p>The first character of this paragraph will be 5em big as defined
in the CSS rule above. Rest of the characters in this paragraph
will remain normal. This example shows how to use :first-letter pseduo
element to give effect to the first characters of any HTML element.
</p>
</body>
</html>
相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

