在 CSS 中哪個元素用於為選擇器中的文字的首字母新增特殊樣式


使用 :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>

更新於:13-Mar-2020

83 次瀏覽

開啟你的職業生涯

完成課程以獲得認證

開始學習
廣告