DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> CSS入門知識 >> 關於CSS >> CSS基礎教程:CSS的偽元素Pseudo Elements
CSS基礎教程:CSS的偽元素Pseudo Elements
編輯:關於CSS     
偽元素吸附在選擇上和pseudo classes偽類很像,像這樣selector:pseudoelement{property: value;}。有四種方式。

First letters and First lines 首字母和首行

  first-letter偽元素作用到元素的第一個字母,first-line作用到元素的頂行。你可以,例如為段落創建一個drop caps和首行加粗。

p:first-letter {
    font-size: 3em;
    float: left;
}

p:first-line {
    font-weight: bold;
}


Before and after 前後

  before和after用來聯系content屬性不使用HTML確定一個元素的內容位置。
  content屬性值可以是:open-quote,close-quote,no-open-quote,no-close-quote,在引號標記裡關閉任何字符串或使用url(imagename)圖片。

blockquote:before {
    content: open-quote;
}
blockquote:after {
    content: close-quote;
}
li:before {
    content: "POW: "
}
p:before {
    content: url(images/jam.jpg)
}


  聽起來不錯吧,可惜大部分用戶不能體會到before或after的效果,因為IE不支持。
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved