首頁  >  文章  >  web前端  >  css3中content的用法是什麼

css3中content的用法是什麼

WBOY
WBOY原創
2021-12-29 16:33:211894瀏覽

在css3中,content屬性與「:before」及「:after」偽元素搭配使用,用於在元素的前後插入內容,語法為「元素:before{content:"插入的內容" ;}」和「元素:after{content:"插入的內容";}」。

css3中content的用法是什麼

本教學操作環境:windows10系統、CSS3&&HTML5版、Dell G3電腦。

css3中content的用法是什麼

content 屬性與 :before 及 :after 偽元素搭配使用,來插入內容。

語法如下:

content: normal|none|counter|attr|string|open-quote|close-quote|no-open-quote|no-close-quote|url|initial|inherit;

其中:

css3中content的用法是什麼

#範例如下:

<html>
<head>
<meta charset="utf-8">
<title>123</title>
<style>
p:before { 
  content:"好好学习,";
}
</style>
</head>
<body>
<p>天天向上</p>
</body>
</html>

輸出結果:

css3中content的用法是什麼

(學習影片分享:css影片教學

以上是css3中content的用法是什麼的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn