


How to use selectors to insert required content into the page in css3 (code attached)
The content of this article is about how to use CSS3 selectors to insert the required content into the page. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
1 Use a selector to insert content
Use the after or before selector to define the content to be inserted in the content attribute of the selector. When the inserted content is text When inserting text, you must add single or double quotes on both sides of the inserted text.
<style type="text/css"> h2:before{ content:‘COLUMN’;} </style>
2 Specify individual elements not to be inserted
Use the none attribute value of the content attribute
<style type="text/css"> h2.sample:before{ content:none;} </style>
3 Insert image files
<style type="text/css"> h2:before{ content:url(mark.png);} </style>
4 Display the value of the alt attribute as the title of the image
By specifying the form of "attr (attribute name)" in the content attribute, you can The attribute values of each attribute are displayed.
img:after{ content:attr(alt); display:block; text-align:center; }
5 Use the content attribute to insert the item number
(1) Add consecutive numbers before multiple titles
1. In the content attribute Use the counter attribute value to append consecutive numbers to multiple items
2. You also need to add the specification of the counter-increment attribute of the element in the element's style. In order to use continuous numbering, you need to set the attribute value of the counter-increment attribute to the before selector or after selector. The counter name specified in the counter attribute value.
h1:before{content:counter(mycounter);} h1{counter-increment:mycounter;}//1、2、3.......
(2) Append text to the item number
h1:before{content:‘第’counter(mycounter)‘章’;}//第1章大标题、第2章大标题.........
(3) Specify the type of number
1. Using the content attribute of the before selector or after selector, you can add not only numeric numbers, but also alphabetical numbers or Roman numeral numbers.
content: counter (counter name, numbering type)
2. You can use the value of the list-style-type attribute to specify the numbering type. For example, when numbering in uppercase letters, use "upper- alpha" attribute, use the "upper-roman" attribute when specifying uppercase Roman letters.
h1:before{content:counter(mycounter,upper-alpha)‘.’;}// A.、B.、C.、
(4) Number nesting
h1:before{content:counter(mycounter);}//1(1、2、3...)、2(1、2、3...)、........ h1{counter-increment:mycounter;counter-reset:subcounter;}(将中编号进行重置) h2:before{content:counter(subcounter);} h2{counter-increment:subcounter;margin-left:40px}
(5) Embed large numbers in middle numbers
h2:before{content:counter(mycounter)‘-’ counter(subcounter)‘.’;}//1-1、1-2
(6) Add nested text symbols on both sides of the string
1. You can use the open-quote attribute value and close-quote attribute value of the content attribute to add nested text symbols such as brackets, single quotes, and double quotes on both sides of the string.
2. The open-quote attribute value is used to add the beginning of the nested text symbol, and the close-quote attribute value is used to add the end of the nested text symbol.
3. Use the quotes attribute in the style of the element to specify what nested text symbols to use
h1:before{ content:open-quote; } h1:after { content:close-quote; } h1{ quotes:"(" ")" }//形如: (标题)
Related recommendations:
CSS3 Series 1 (Overview, Selection , use selectors to insert content)_html/css_WEB-ITnose
How to insert content into the page in css3
The above is the detailed content of How to use selectors to insert required content into the page in css3 (code attached). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to achieve wave effect with pure CSS3? This article will introduce to you how to use SVG and CSS animation to create wave effects. I hope it will be helpful to you!

Web front-end frameworks include: 1. Angular, a front-end framework for creating a single application interface; 2. React, a JavaScript development framework for building user interfaces; 3. Vue, a progressive framework for building user interfaces JavaScript framework; 4. Bootstartp, a front-end framework based on HTML, CSS, and JavaScript; 5. QUICK UI, a set of enterprise-level web front-end development solutions; 6. SUI, a front-end component library.

This article will show you how to use CSS to easily realize various weird-shaped buttons that appear frequently. I hope it will be helpful to you!

Two methods: 1. Using the display attribute, just add the "display:none;" style to the element. 2. Use the position and top attributes to set the absolute positioning of the element to hide the element. Just add the "position:absolute;top:-9999px;" style to the element.
![[Hematemesis Compilation] The latest front-end interview questions and answers in 2023 (Collection)](https://img.php.cn/upload/article/000/000/024/62bbc4b816943531.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
This article summarizes some selected Web front-end interview questions worth collecting (with answers). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

A web front-end engineer is an engineer who is engaged in Web front-end development. His main job is to develop, optimize, and improve the website. His main responsibility is to use various professional technologies to develop client products, and then combine the back-end development technology to simulate the overall effect and provide the website with The products and services provided on realize first-class web interfaces, optimize code and maintain good compatibility, and are committed to improving user experience through technology.

In CSS, you can use the border-image attribute to achieve a lace border. The border-image attribute can use images to create borders, that is, add a background image to the border. You only need to specify the background image as a lace style; the syntax "border-image: url (image path) offsets the image border width inward. Whether outset is repeated;".

How to create text carousel and image carousel? The first thing everyone thinks of is whether to use js. In fact, text carousel and image carousel can also be realized using pure CSS. Let’s take a look at the implementation method. I hope it will be helpful to everyone!
