Ideas
The idea is very simple, is a word to write two times, a word only show part, but can not really write a word two times. Here you need to use CSS pseudo elements: Before and: After, remember this "pseudo element" of the word "pseudo", that it was not there. Our approach is to place the same character in the pseudo element, showing only half of it, while the original character shows the other half, and finally they are spelled into a word.
CSS Code
CSS code copy content to clipboard
- . HF {
- Display:inline-block;
- font-size:80px;
- line-height:80px;
- Color: #000;
- position:relative;
- Overflow:hidden;
- whitewhite-space:pre;/* Processing Space * *
- }
- . hf:before {
- Position:absolute;
- left:0;
- top:0;
- Color: #f00;
- Display:block;
- width:30%;/* If you want to change half the text, set the 50%*/
- Content:attr (data-content)//* pseudo element dynamic gain content * *
- Overflow:hidden;
- }
HTML Code
xml/html code to copy content to clipboard
- <span class= "HF" data-content= "W" >W</span>
- <span class= "HF" data-content= "E" >e</span>
- <span class= "HF" data-content= "B" >b</span>
- <span class= "HF" data-content= "front" > Front </span>
- <span class= "HF" data-content= "End" > End </span>
Demo
Attached: W3school: Before and: after pseudo element explanation
CSS2-: Before pseudo element
The ": Before" pseudo element can insert new content before the content of the element.
The following example inserts a picture before each
CSS code copy content to clipboard
- H1:before
- {
- Content:url (logo.gif);
- }
Give it a shot yourself.
CSS2-: After pseudo element
After the pseudo element can insert new content after the element's contents.
The following example inserts a picture after each
CSS code copy content to clipboard
- H1:after
- {
- Content:url (logo.gif);
- }
Try it yourself