在css3中,content屬性與“:before”及“:after”偽元素配合使用,用于在元素的前后插入內(nèi)容,語法為“元素:before{content:"插入的內(nèi)容";}”和“元素:after{content:"插入的內(nèi)容";}”。
本教程操作環(huán)境:windows10系統(tǒng)、CSS3&&HTML5版、Dell G3電腦。
css3中content的用法是什么
content 屬性與 :before 及 :after 偽元素配合使用,來插入內(nèi)容。
語法如下:
content: normal|none|counter|attr|string|open-quote|close-quote|no-open-quote|no-close-quote|url|initial|inherit;
其中:
示例如下:
<html> <head> <meta charset="utf-8"> <title>123</title> <style> p:before { content:"好好學(xué)習(xí),"; } </style> </head> <body> <p>天天向上</p> </body> </html>
輸出結(jié)果:
(學(xué)習(xí)視頻分享:css視頻教程)