css怎麼實現字型放大特效?(首字元變化代碼實測)

來源:互聯網
上載者:User
css在網頁製作中有著在非常重要的作用,一個頁面或者頁面中的一篇文章除了內容上的吸引力,如何在樣式上抓住使用者的眼球呢?比如本篇文章就是介紹css字型放大的特效及css首字元放大的效果展示實現。有需要的朋友可以參考下。

css字型放大特效具體程式碼範例如下:

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>首字母放大測試</title></head><body><div class="contain">    <p>This is the CSS test</p>    <p>This is the CSS test</p>    <p>這是一個css測試</p></div></body></html>

style.css代碼如下:

<style>    body {        background-color: #FFFFFF;        color: #595959;    }    .contain {        width: 150px;    }    .contain p {        font: 80%/1.6 Verdana, Geneva, Arial, Helvetica, sans-serif;    }    .contain p:first-letter {        font-size: 2em;        padding: 0.1em;        color: #000000;        vertical-align: middle;    }    .contain p:first-line {        color: red;    }    .contain p:first-child:first-letter {        color: red;    }    .contain p:first-child:first-line {        color: inherit;    }</style>

本地代碼測試結果如下:

注意::first-letter 選取器用於選取指定選取器的首字母。並且first-letter支援IE7+,first-line支援IE8+

以下屬性可與 :first-letter 使用:

字型屬性

顏色屬性

背景屬性

外邊距屬性

內邊距屬性

邊框屬性

text-decoration

vertical-align(只有在 float 為 'none' 時)

text-transform

line-height

float

clear

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.