怎么在css3在页面中插入内容

PHP中文网
发布: 2017-06-22 11:38:13
原创
2026 人浏览过

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学习者快速成长!