Use css to set a half-text style code example, css style code

Source: Internet
Author: User

Use css to set a half-text style code example, css style code

Sample Code for setting a half-text style using css:
Generally, when you set the text style and effect, the entire text will be effective. For example, if you set the color of the text, the entire text will change color, the following describes how to set a specified style for a part of the text, hoping to provide some help to friends in need.
The Code is as follows:

<! DOCTYPE html> 

The above Code meets our requirements. Only half of the text in the string is set to Red. The following describes how it works.
I. Implementation principle:
The effect looks dazzling. In fact, the principle is very simple. It is used in combination with the before pseudo element selector and the content attribute to add a pseudo element to the span element, at the same time, set the element content to the data-content attribute value of the span element, and set it to absolute positioning so that it overwrites the original span element, with the width half of the original span element, then we set the font color in the element to meet our requirements. It looks like a text, but it is actually a combination of two texts.
Ii. Related reading:
1. For details about before, see section before/E: before, a pseudo-object selector of CSS.
2. For details about the content attribute, see the content attribute section of CSS.

The original address is: http://www.softwhy.com/forum.php? Mod = viewthread & tid = 14781.

For more information, see: http://www.softwhy.com/divcss/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.