css選擇符種類和簡單應用

來源:互聯網
上載者:User

這些選擇符總體可以分為以下幾類:

   (1) 為某個特定的元素名定義樣式,這樣,網頁中所有的該元素都可以應用該樣式。

    (2)為某個特定的class屬性名稱定義樣式,這樣,網頁中所有的class屬性值為該屬性名稱的元素都可以應用該樣式

    (3)為某個特定的元素定義樣式,該元素使用id屬性來標示,樣式也同樣是使用id屬性值來定義。

    (4)為某些特定用途定義的使用以上3類無法實現的選擇符,包括偽類和虛擬元素選擇符等


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>CSS選擇符</title><style type="text/css">  h1 { border-width: 1; border: solid; }  h1.myclass { border-width: 1; border: solid; }  h1#myid { border-width: 1; border: solid; }  h1::first-letter { border-width: 1; border: solid; }</style></head><body>    <h1>將應用元素名定義</h1>    <h1 class="myclass">將應用類定義和元素名定義</h1>    <h1 id="myid">將應用id定義和元素名定義</h1></body></html>


相關文章

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.