怎麼在css3在頁面插入內容

PHP中文网
發布: 2017-06-22 11:38:13
原創
2025 人瀏覽過

A 使用選擇器插入內容

h2:before{
  content:"前缀";
}
h2:after{
  content:"后缀";
}
登入後複製

B 指定個別的元素不進行插入

h2.sample:before{
  content:none;
}
登入後複製

2. 插入圖片

A 在標題前插入圖片檔案

h2:before{
  content:url(anwy.jpg);
}
登入後複製

B alt屬性的值作為圖像的標題來顯示(用不了)

img:after{
  content:attr(alt);
  display:block;
  text-align:center;
  margin-top:5px;
  font-size:11px;
  font-weight:bold;
  color:black;
}
登入後複製

3. 插入編號

A#.  多個標題前加入連續編號

p:before{
  content:counter(pCounter);
}
p{
  counter-increment:pCounter;
}
登入後複製

B 在項目符號中追加文字

p:before{
  content:"第"counter(pCounter)"段";
}
登入後複製

C 指定編號樣式、類型

p:before{
  content:counter(pCounter,upper-alpha)'.';
  color:blue;
  font-size:16px;
}
登入後複製

D#.  編號巢狀

p:before{
  content:counter(pCounter,upper-alpha)'.';
  color:blue;
  font-size:16px;
}
p{
  counter-increment:pCounter;
  counter-reset:subDivCounter;
}
p:before{
  content:counter(subDivCounter)'.';
  margin-left:15px;
 
  font-size:12px;
}
p{
  counter-increment:subDivCounter;
}
登入後複製

E 字串兩邊新增文字巢狀符號

h3:before{
  content: open-quote;
}
h3:after{
  content: close-quote;
}
h3{
  quotes:"【""】";
}
登入後複製

disc | circle圓圈 | square正方形 | decimal數字 | decimal-leading-zero 十進制數| lower-roman 小寫羅馬文字| upper-roman 大寫羅馬文字| lower-greek小寫希臘字母 | lower-latin小寫拉丁文 | upper-latin 大寫拉丁文| armenian亞美尼亞數字 | georgian喬治亞數字 | lower-alpha小寫英文字母 | upper-alpha大寫英文字母 | none | inherit繼承

以上是怎麼在css3在頁面插入內容的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!