HTML5----CSS display half characters

Source: Internet
Author: User

The basic idea of CSS display with half characters is as follows:

It is a single word written twice, showing half of each word. Here we need to use the CSS pseudo elements: before AND: after. Remember the "pseudo" word of this "pseudo element", which indicates that it does not exist. Our method is to place the same characters in the pseudo element and display only half, while the original character shows the other half, and finally splice them into one word.


:



CSS:

<Style type = "text/css">. halfStyle {position: relative; display: inline-block; font-size: 100px;/* any width can be */color: black;/* any color, or transparent */overflow: hidden; white-space: pre;/* processing space */font-family: Microsoft YaHei; font-weight: bold ;}. halfStyle: before {display: block; z-index: 1; position: absolute; top: 0; left: 0; width: 50%; content: attr (data-content ); /* Dynamically Retrieve pseudo elements */overflow: hidden; color: # f00 ;}</style>


HTML:

<Span class = "halfStyle" data-content = "to"> to </span> <span class = "halfStyle" data-content = "this"> This </span> <span class = "halfStyle" data-content = "1"> 1 </span> <span class = "halfStyle" data-content = ""> game </span>






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.