.spritePlayVideoButton
{
text-indent: -2000em;
display: block;
border: 0px;
width: 120px;
height: 24px;
background-color: #ffffff;
background-image: url(http://static.howstuffworks.com/en-us/default/layout/hsw_article_sprite_2.gif);
background-repeat: no-repeat;
background-position: 0px 0px;
}
.spriteGoButton
{
display: block;
width: 30px;
height: 19px;
background-image: url(http://static.howstuffworks.com/en-us/default/layout/hsw_article_sprite_2.gif);
background-repeat: no-repeat;
background-position: 0px -24px;
}
.spriteFacebookIcon
{
width: 13px;
height: 13px;
background-image: url(http://static.howstuffworks.com/en-us/default/layout/hsw_article_sprite_2.gif);
background-repeat: no-repeat;
background-position: 0px -253px;
border: 0px;
}
ဒီမှာ CSS style sheet ရဲ့ position ကိုသုံးသွားတာပါပဲ။ ပုံမှာကြည့်ပါ background image ကို လိုအပ်တဲ့နေရာလောက် အပေါ်ဘယ်ထောင့်ကနေပြီး လိုအပ်သလောက်လေးပဲ height နဲ့ width ကို ယူသွားတာပါပဲ။ တကယ်နေရာမှာ background-position(x y) ကနေပြီး height နဲ့ width ကိုတွက်ပြီး background ပေါ်မှာပါ။ ဥပမာ. Go button အတွက်ဆိုပါတော့။ မူလ position ကို 0 နဲ့ -24 (အောက်) ပေးထားပါတယ်။ အဲဒီအမှတ်ကနေပြီး height နဲ့ width ရှိသလောက်လေးပဲ ပေါ်မှာပါ။ ဒါဆိုရင် ပုံသေးသေးလေးတွေအတွက် CSS မှာ ရှင်းရှင်းလင်းလင်း ရေးလို့ရသွားပါပြီ။
Tuesday, January 05, 2010
min that thant
Posted in 
No Response to "CSS Icon Background Image Sprites"
Post a Comment