在 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>

更新於:2020 年 3 月 13 日

83 人觀看

開始您的職業生涯

完成課程獲得認證

開始學習
廣告
© . All rights reserved.