Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

How make an image sprite 100% responsive with css only

License

Notifications You must be signed in to change notification settings

alexx855/Responsive-CSS-image-sprites

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

What is it?

gif

How it works?

Attribute How to calculate
Padding bottom (icon height / icon width) * 100%
Background size (sprite width / icon width) x 100
Background pos x (x pixel pos / (sprite width - icon width)) x 100
Background pos Y (y pixel pos / (sprite height - icone height)) x 100

So, our SCSS should look like this:

.icon{
  display: inline-block;
  &::before{
    content: '';
    display: block;
    width: 100%;
    height: 0;
    background: url('../images/goggles_features.png') no-repeat;
  }
}

.icon--one{
  width: 20%;
  &::before{
    background-position: 59.111% 50%;
    padding-bottom: 92.42%;
    background-size: 440.91%;
  }
}

Example

You can found two examples what i've used on my projects in this repository.

Notes

Any comment, suggestion or star are apreciate :)

About

How make an image sprite 100% responsive with css only

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published