css :before的用法

<style>

ol>li {

  list-style-type:none;

  counter-increment:item;

}

ol>li:before {

  width:1.5em;

  font-weight:bold;

  content:counter(item) ".";

}

</style>

<html>

   <ol>

     <li>a</li>

     <li>b</li>

     <li>c</li>

   </ol>

</html>

run result:

1.a

2.b

3.c

note:  :before 是指設置 'content'的內容樣式。 

counter 是動態設置li的序列樣式,item-->:before item.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章