css content 属性与 :before 及 :after 伪元素配合使用,来插入生成内容
| 默认值 | normal |
|---|---|
| 继承 | no |
| 版本 | CSS2 |
| JavaScript 语法 | object.style.content="url(beep.wav)" |
content : none | normal| counter ...| 值 | 说明 |
|---|---|
| none | 设置Content,如果指定成Nothing |
| normal | 设置content,如果指定的话,正常,默认是"none"(该是nothing) |
| counter | 设定计数器内容 |
| attr(attribute) | 设置Content作为选择器的属性之一 |
| string | 设置Content到你指定的文本 |
| open-quote | 设置Content是开口引号 |
| close-quote | 设置Content是闭合引号 |
| no-open-quote | 如果指定,移除内容的开始引号 |
| no-close-quote | 如果指定,移除内容的闭合引号 |
| url(url) | 设置某种媒体(图像,声音,视频等内容) |
| inherit | 指定的content属性的值,应该从父元素继承 |
所有主流浏览器都支持 content 属性
IE8 只有指定 <!DOCTYPE html> 才支持 content 属性
下面的 CSS 样式将在每个链接后的括号内加上网址
a:after
{
content: " (" attr(href) ")";
}本文内容仅供个人学习/研究/参考使用,不构成任何决策建议或专业指导。分享/转载时请标明原文来源,同时请勿将内容用于商业售卖、虚假宣传等非学习用途哦~感谢您的理解与支持!