Categories
Css

CSS Image Sprites

Image sprite is nothing but a collection of images put into a single image. When web page loads then for a particular location we show particular position of a image. For multiple images it takes time to load on a server. That is why we use single image for multiple position to save bandwidth.

You may like:  Difference between @import and link

In the following example we will show how we can show one image into to parts using Image Sprites:

<!DOCTYPE html>
<html>
<head>
<style>
#img1{
width: 151px;
height: 400px;
background: url(sprite.png) 0 0;
}

#img2{
width: 151px;
height: 400px;
background: url(sprite.png) -148px 0;
}
</style>
</head>
<body>

<img id="img1" src="img_trans.gif"><br />
<img id="img2" src="img_trans.gif">

</body>
</html>
sprite2
Avatar for Namaste UI (Author)

By Namaste UI (Author)

Namaste UI collaborates closely with clients to develop tailored guest posting strategies that align with their unique goals and target audiences. Their commitment to delivering high-quality, niche-specific content ensures that each guest post not only meets but exceeds the expectations of both clients and the hosting platforms. Connect with us on social media for the latest updates on guest posting trends, outreach strategies, and digital marketing tips. For any types of guest posting services, contact us on info[at]namasteui.com.

Leave a Reply

Your email address will not be published. Required fields are marked *