I have an app that has lots of icons. I know that using sprites for these icons is the correct way instead of having multiple small images. However, I needed those icons to be the same size as the container (background-size: contain;
), so I was forced to use multiple images for each icon:
.icon1 {
background-image: url('../my-site/icon1.gif');
background-size: contain;
}
.icon2 {
background-image: url('../my-site/icon2.gif');
background-size: contain;
}
. . . and so on...
Using sprites however, would result to:
(without
background-size: contain;
) - image is so small when i.e button is big(using
background-size: contain;
) - the whole sprite is being shown to the container!
Is there a way to use a responsive sprite that would show the icon (using background-position
) and making that icon 100% width and height of container?