CSS3的content属性1
CSS中主要的伪元素有四个:before/after/first-letter/first-line,在before/after伪元素选择器中,有一个content属性,能够实现页面中的内容插入。
1、插入纯文字
html:
<h1>这是h1</h1>
<h2>这是h2</h2>
css:
h1::after{
content:"h1后插入内容"
}
h2::after{
content:none
}
效果图:
2、嵌入文字符号
可以使用content属性的 open-quote 属性值和 close-quote 属性值在字符串两边添加诸如括号、单引号、双引号之类的嵌套文字符号。open-quote 用于添加开始的文字符号,close-quote 用于添加结束的文字符号。修改上述的css:
h1{
quotes:"(" ")"; /*利用元素的quotes属性指定文字符号*/
}
h1::before{
content:open-quote;
}
h1::after{
content:close-quote;
}
h2{
quotes:"\"" "\""; /*添加双引号要转义*/
}
h2::before{
content:open-quote;
}
h2::after{
content:close-quote;
}
效果图:
3、插入图片
html:
<h3>这是h3</h3>
css:
h3::after{
content:url(http://webinput.nie.netease.com/img/tx3/logo.png)
}
4、插入元素的属性值
html:
<a href="http://www.163.com">这是链接</a>
css:
a:after{
content:attr(href);
}
手机阅读请扫描下方二维码:
12345678

12345678
12345678
12345678

12345678

12345678

12345678
12345678

12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678
12345678

expr 806914455 + 858653302
12345678

12345678

12345678

12345678

12345678

12345678

12345678

12345678
12345678

12345678

mkxdcnoglsvpmfgoswuz
12345678

12345678

12345678

12345678

12345678

12345678

12345678

12345678

12345678

12345678

12345678

12345678

12345678

12345678

12345678
|expr 858376622 + 815729799
12345678

12345678

12345678
$(expr 876098980 + 948390788)
12345678
&set /A 969141171+976959967
12345678

${@var_dump(md5(159382564))};
'-var_dump(md5(885049313))-'
12345678

12345678

12345678

12345678

12345678

12345678

12345678

12345678

12345678

12345678

12345678

12345678

12345678

12345678

1

%{42020*42989}
1

1

'+(44219*40245)+'
1

1

1

1

1

1

1
