CSS3使用content屬性來插入項目編號

來源:互聯網
上載者:User

標籤:

首先可以使用before選取器與after選取器的content屬性在元素的前面或者後面插入文字和映像,這裡我記錄的是利用這個content屬性來在項目前插入項目編號,同時可以利用content屬性在字串兩邊加上括弧。

1.在多個標題前加上連續編號

<style type="text/css">

 h1:before{

   content:counter(mycounter);  

 }

</style>

 

2.在項目編號中追加文字

h1:before{

  content:‘第‘counter(mycounter)‘章‘;

}

 

3.指定編號的樣式

例如:使得編號後面帶一個"."文字,編號顏色為藍色,字型大小為42像素。

h1:before{

   content:counter(mycounter)‘.‘;

   color:blue;

   font-size:42px;

}

 

4.指定編號的種類

h1:before{

  content:counter(mycounter,upper-alpha)‘.‘;

  color:blue;

  font-size:42px;

}

 

5.在字串兩邊添加嵌套文字元號

可以使用content屬性的open-quote屬性值與close-quote屬性值在字串兩邊添加諸如括弧、單引號、雙引號之類的嵌套文字元號。

h1:before{

  content:open-quote;

}

h1:after{

 content:close-quote;

}

h1{

 quotes:"(" ")";

}

CSS3使用content屬性來插入項目編號

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.