使用before和after选择器向页面中插入文字图片编号引号
2017-10-29 18:41
351 查看
使用选择器在页面中插入内容
使用什么选择器?伪元素选择器before和after。
如何插入?使用before或after选择器的content属性。
插入什么内容?文字,图片,项目编号。注意,当插入文字时,需要在文字两旁加上双引号。
<html>
<head>
<meta charset = "UTF-8">
<style type = "text/css">
h1:before
{
content: counter(counter1)".";
}
h1
{
counter-increment:counter1;
counter-reset:counter2;
}
h2:before
{
content: counter(counter2)".";
}
h2
{
counter-increment:counter2;
margin-left:40px;
}
p:before
{
content:"COLUMN";
content:url(1.jpg);
content:"第"counter(my_counter, upper-roman)"句";
content:open-quote;
color:white;
background-color:orange;
padding:1px 5px;
margin-right:10px;
}
p:after
{
content:"COLUMN";
content:url(1.jpg);
content:close-quote;
color:white;
background-color:orange;
padding:1px 5px;
margin-right:10px;
}
p
{
counter-increment:my_counter;
}
p.exception:before
{
content:none;
}
p.exception:after
{
content:normal;
}
</style>
</head>
<body>
<h1>A</h1>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h1>B</h1>
<h2>bbb</h2>
<h2>bbb</h2>
<h2>bbb</h2>
<h1>C</h1>
<h2>ccc</h2>
<h2>ccc</h2>
<h2>ccc</h2>
<p>黄河远上白云边</p>
<p class = "exception">一片孤云万韧山</p>
<p>羌笛何须怨杨柳</p>
<p>春风不度玉门关</p>
</body>
</html>
使用什么选择器?伪元素选择器before和after。
如何插入?使用before或after选择器的content属性。
插入什么内容?文字,图片,项目编号。注意,当插入文字时,需要在文字两旁加上双引号。
<html>
<head>
<meta charset = "UTF-8">
<style type = "text/css">
h1:before
{
content: counter(counter1)".";
}
h1
{
counter-increment:counter1;
counter-reset:counter2;
}
h2:before
{
content: counter(counter2)".";
}
h2
{
counter-increment:counter2;
margin-left:40px;
}
p:before
{
content:"COLUMN";
content:url(1.jpg);
content:"第"counter(my_counter, upper-roman)"句";
content:open-quote;
color:white;
background-color:orange;
padding:1px 5px;
margin-right:10px;
}
p:after
{
content:"COLUMN";
content:url(1.jpg);
content:close-quote;
color:white;
background-color:orange;
padding:1px 5px;
margin-right:10px;
}
p
{
counter-increment:my_counter;
}
p.exception:before
{
content:none;
}
p.exception:after
{
content:normal;
}
</style>
</head>
<body>
<h1>A</h1>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h1>B</h1>
<h2>bbb</h2>
<h2>bbb</h2>
<h2>bbb</h2>
<h1>C</h1>
<h2>ccc</h2>
<h2>ccc</h2>
<h2>ccc</h2>
<p>黄河远上白云边</p>
<p class = "exception">一片孤云万韧山</p>
<p>羌笛何须怨杨柳</p>
<p>春风不度玉门关</p>
</body>
</html>
相关文章推荐
- Css3(02)使用选择器插入内容(before/after)
- 【JQuery】使用before()和after()在元素前后插入内容
- CSS3之使用选择器在页面中插入内容
- 使用选择器在页面中插入
- 使用选择器在页面中插入内容
- 使用JavaScript将当前页面保存成PDF,支持图片和文字的保存
- CSS3选择器/使用content属性来插入项目编号
- css3之使用选择器在页面中插入内容
- css3 - 使用选择器在页面中插入内容
- 使用SVGWeb在页面中插入svg图片
- 【阅读】《Head First jQuery》第二章——选择器与方法(一个点击图片页面显示文字的小例子)
- 在页面上的输入框中即可以输入文字,又可以动态的插入图片的功能.
- 使用matlab在图片中插入文字并保存
- 使用选择器在页面中插入内容
- 伪类选择器 before 和after的使用 实例 制作圆角
- 【jQuery】使用before()和after()在元素前后插入内容
- 使用 javascript 函数 完美控制页面图片显示大小(第二版) By shawl.qiu
- 如何使用页面来抓取摄像头图片实现拍照
- JSP页面中使用中文名图片
- 使用FileUpload控件上传图片并自动生成缩略图、自动生成带文字和图片的水印图