<div class="my-sprite"></div>
.my-sprite {
background-image: url("https://cdn.pbrd.co/images/HkKj0eC.png");
height:100px;
width:100px;
background-position: 0 0;
background-position:-200px 0px;
}
I can not get my sprites to scale to a smaller dimension. I want it to be like half of the actual size which is 100x100px how can I scale it with background-size
property? Right now it only shows the full image size of 100x100px...
Your image sprite has a dimension of 500x400 so define half this size if you want to reduce by 2 on the
background-size
then adjust thebackground-position
to get any icon you want:You can decrease more by any scale number, you simply need to do the correct calculation
Here is a generic formula by using CSS variable for the scale number and also for selecting the icon.
You could use
transform:scale()
.