CSS Sprites image background Optimization Technology

Source: Internet
Author: User

From: Blue

Playing cards

This article introduces a simple implementation method, which does not require an image.
The principle is to use HTML tags with four special characters.
1. & spades; indicates the peach
2. & Hearts; indicates a red heart
3. & clubs; indicates plum blossom
4. & diams; indicates the square
Write the structure first:
<Div class = "card" style = "Left: 10px; top: 20px;">
<Div class = "Front">
<B class = "Index"> 9 <br/> & spades; </B>
<SPAN class = "A1"> & spades; </span>
<SPAN class = "A2"> & spades; </span>
<SPAN class = "A3"> & spades; </span>
<SPAN class = "A4"> & spades; </span>
<SPAN class = "B1"> & spades; </span>
<SPAN class = "C1"> & spades; </span>
<SPAN class = "C2"> & spades; </span>
<SPAN class = "C3"> & spades; </span>
<SPAN class = "C4"> & spades; </span>
<B class = "end"> & spades; <br/> 9 </B>
</Div>
</Div>
Then write the style:
<Style type = "text/CSS">
. Card {width: 125px; Height: 170px; position: absolute; overflow: hidden; Border: 1px # c0c0c0 solid ;}
/* General settings of intermediate images */
SPAN {
Display: block;
Width: 20px;
Height: 30px;
Line-Height: 30px;
Position: absolute;
Font-size: 26px;
Left: 22px;
Top: 130px;
}
/* General settings for small images */
/* General numeric settings */
B {display: block; width: 15px; Height: 10px; position: absolute; font-size: 10px; text-align: center; font-weight: bold; overflow: hidden ;}
/* Coordinate points */
. A1 {left: 21px; top: 10px ;}
. A2 {left: 21px; top: 50px ;}
. A3 {left: 21px; top: 90px ;}
. A4 {left: 21px; top: 130px ;}
. B1 {left: 51px; top: 76px ;}
. C1 {left: 83px; top: 10px ;}
. C2 {left: 83px; top: 50px ;}
. C3 {left: 83px; top: 90px ;}
. C4 {left: 83px; top: 130px ;}
. Scroll {filterrogidximagetransform. Microsoft. basicimage (rotation = 2); Height: 1px}
. Index {
Font-size: 16px;
Font-weight: bold;
Text-align: center;
Width: 14px;
Height: 36px;
Position: absolute;
Left: 5px;
Top: 0px;
}
. End {
Font-size: 16px;
Font-weight: bold;
Text-align: center;
Width: 14px;
Height: 36px;
Position: absolute;
Right: 5px;
Bottom: 0px;
}
. Red {color: # ff0000 ;}
. Font {font-size: 34px ;}
</Style>
Note: In order to truly restore a playing card, I added the filter function to the second playing card to flip the following pattern vertically, but this method will cause the picture to be unclear, in addition, this method can only be identified by IE browsers. If the experts have other better methods, please kindly advise!

 

CompleteCodeAs follows:

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
<Style type = "text/CSS">
. Card {width: 125px; Height: 170px; position: absolute; overflow: hidden; Border: 1px # c0c0c0 solid ;}
/* General settings of intermediate images */
SPAN {
Display: block;
Width: 20px;
Height: 30px;
Line-Height: 30px;
Position: absolute;
Font-size: 26px;
Left: 22px;
Top: 130px;
}
/* General settings for small images */
/* General numeric settings */
B {display: block; width: 15px; Height: 10px; position: absolute; font-size: 10px; text-align: center; font-weight: bold; overflow: hidden ;}
/* Coordinate points */
. A1 {left: 21px; top: 10px ;}
. A2 {left: 21px; top: 50px ;}
. A3 {left: 21px; top: 90px ;}
. A4 {left: 21px; top: 130px ;}
. B1 {left: 51px; top: 76px ;}
. C1 {left: 83px; top: 10px ;}
. C2 {left: 83px; top: 50px ;}
. C3 {left: 83px; top: 90px ;}
. C4 {left: 83px; top: 130px ;}
. Scroll {filter: progid: DXImageTransform. Microsoft. basicimage (rotation = 2); Height: 1px}
. Index {
Font-size: 16px;
Font-weight: bold;
Text-align: center;
Width: 14px;
Height: 36px;
Position: absolute;
Left: 5px;
Top: 0px;
}
. End {
Font-size: 16px;
Font-weight: bold;
Text-align: center;
Width: 14px;
Height: 36px;
Position: absolute;
Right: 5px;
Bottom: 0px;
}
. Red {color: # ff0000 ;}
. Font {font-size: 34px ;}
</Style>
</Head>
<Body>
<! -- 9 characters -->
<Div class = "card" style = "Left: 10px; top: 20px;">
<Div class = "Front">
<B class = "Index"> 9 <br/> </B>
<SPAN class = "A1"> </span>
<SPAN class = "A2"> </span>
<SPAN class = "A3"> </span>
<SPAN class = "A4"> </span>
<SPAN class = "B1"> </span>
<SPAN class = "C1"> </span>
<SPAN class = "C2"> </span>
<SPAN class = "C3"> </span>
<SPAN class = "C4"> </span>
<B class = "end"> <br/> 9 </B>
</Div>
</Div>
<! -- 9 characters -->
<Div class = "card" style = "Left: 175px; top: 20px;">
<Div class = "Front Red">
<B class = "Index"> 9 <br/> </B>
<SPAN class = "A1"> </span>
<SPAN class = "A2"> </span>
<SPAN class = "A3"> </span>
<SPAN class = "A4"> </span>
<SPAN class = "B1"> </span>
<SPAN class = "C1"> </span>
<SPAN class = "C2"> </span>
<SPAN class = "C3"> </span>
<SPAN class = "C4"> </span>
<B class = "end"> <br/> 9 </B>
</Div>
</Div>
<! -- 9 characters -->
<Div class = "card" style = "Left: 340px; top: 20px;">
<Div class = "Front Red">
<B class = "Index"> 9 <br/> </B>
<SPAN class = "A1"> </span>
<SPAN class = "A2"> </span>
<SPAN class = "A3 scroll"> </span>
<SPAN class = "A4 scroll"> </span>
<SPAN class = "B1"> </span>
<SPAN class = "C1"> </span>
<SPAN class = "C2"> </span>
<SPAN class = "C3 scroll"> </span>
<SPAN class = "C4 scroll"> </span>
<B class = "End scroll"> 9 <br/> </B>
</Div>
</Div>
<! -- 9 characters -->
<Div class = "card" style = "Left: 510px; top: 20px;">
<Div class = "Front Red">
<B class = "Index"> 9 <br/> </B>
<SPAN class = "A1 font"> </span>
<SPAN class = "A2 font"> </span>
<SPAN class = "A3 font"> </span>
<SPAN class = "A4 font"> </span>
<SPAN class = "B1 font"> </span>
<SPAN class = "C1 font"> </span>
<SPAN class = "C2 font"> </span>
<SPAN class = "C3 font"> </span>
<SPAN class = "C4 font"> </span>
<B class = "end"> <br/> 9 </B>
</Div>
</Div>
</Body>
</Html>

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.