Skip to content

Commit 9bd8f10

Browse files
authored
Merge pull request #21 from satyam-seth-learnings/image-sprites
Image sprites
2 parents 4aa09af + 7c7fa5a commit 9bd8f10

File tree

5 files changed

+109
-0
lines changed

5 files changed

+109
-0
lines changed

Image Sprites/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[CSS Tricks Blog Link](https://css-tricks.com/css-sprites/)
2+
3+
[W3School Link](https://www.w3schools.com/css/css_image_sprites.asp)
4+
5+
[MDN Article Link](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Images/Implementing_image_sprites_in_CSS)

Image Sprites/demo.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<link rel="stylesheet" href="style.css">
7+
<title>Image Sprites</title>
8+
</head>
9+
<body>
10+
<h1 class="title">Image Sprites Demo</h1>
11+
<div class="original-image">
12+
<h1>ORIGINAL IMAGE</h1>
13+
<img src="sprite.webp" alt="sprite image">
14+
</div>
15+
<div class="result">
16+
<div class="country">
17+
<h1>CANADA</h1>
18+
<div class="flags-canada"></div>
19+
</div>
20+
<div class="country">
21+
<h1>USA</h1>
22+
<div class="flags-usa"></div>
23+
</div>
24+
<div class="country">
25+
<h1>MEXICO</h1>
26+
<div class="flags-mexico"></div>
27+
</div>
28+
</div>
29+
</body>
30+
</html>

Image Sprites/sprite.webp

11.1 KB
Loading

Image Sprites/style.css

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
* {
2+
margin: 0;
3+
padding: 0;
4+
box-sizing: border-box;
5+
}
6+
7+
body {
8+
width: 100%;
9+
height: 100vh;
10+
display: grid;
11+
place-items: center;
12+
grid-template-areas:
13+
"title title"
14+
"original-image result";
15+
color: whitesmoke;
16+
background-color: black;
17+
}
18+
19+
.title {
20+
grid-area: title;
21+
padding: 10px;
22+
place-self: center;
23+
border-radius: 12px;
24+
border: 2px solid greenyellow;
25+
}
26+
27+
.original-image {
28+
grid-area: original-image;
29+
display: grid;
30+
gap: 16px;
31+
place-items: center;
32+
}
33+
34+
.original-image img {
35+
border: 2px solid greenyellow;
36+
}
37+
38+
.result {
39+
grid-area: result;
40+
display: grid;
41+
gap: 16px;
42+
place-items: center;
43+
}
44+
45+
.country {
46+
display: grid;
47+
gap: 16px;
48+
place-items: center;
49+
}
50+
51+
.flags-canada,
52+
.flags-mexico,
53+
.flags-usa {
54+
width: 250px;
55+
background-image: url('sprite.webp');
56+
background-repeat: no-repeat;
57+
border: 2px solid greenyellow;
58+
}
59+
60+
.flags-canada {
61+
height: 128px;
62+
background-position: -5px -5px;
63+
}
64+
65+
.flags-usa {
66+
height: 135px;
67+
background-position: -5px -143px;
68+
}
69+
70+
.flags-mexico {
71+
height: 147px;
72+
background-position: -5px -288px;
73+
}

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<a href="./Scroll Snapping/index.html">Scroll Snapping</a>
5353
<a href="./Orientation Lock/demo.html">Orientation Lock</a>
5454
<a href="./Scratch card effect/demo.html">Scratch card effect</a>
55+
<a href="./Image Sprites/demo.html">Image Sprites</a>
5556
</body>
5657

5758
</html>

0 commit comments

Comments
 (0)