css-sprite | css sprite generator | Theme library
kandi X-RAY | css-sprite Summary
kandi X-RAY | css-sprite Summary
css sprite generator
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of css-sprite
css-sprite Key Features
css-sprite Examples and Code Snippets
Community Discussions
Trending Discussions on css-sprite
QUESTION
I have many small icons in my website. Instead of loading all of them independently, I am thinking of using CSS sprites due to performance gain.
Consider the following code
...ANSWER
Answered 2020-May-16 at 23:59If your sprite size is 200x200 px, and you want to get better resolution by zooming - make you background-size: 100px 100px;
. So if you will zoom to 200% - the quality of you image will still be good. Obviously, your sprite image should be twice bigger the size you are going to use on your website. To avoid problems - do not mix %
and px
or any other different units in one background-size
. Use only px
in your case and everything will work just fine.
Summarizing. Make sprite twice bigger, set background-size
twice smaller the size of sprite image. Tested it in Chrome and FF. Works fine on zooming.
If you are familiar with svg
files - try to do your own vector font (for icons) using http://fontastic.me/. No scaling issues will disturb you. You can set size by font-size
and make them any color by color
in CSS, like a text.
QUESTION
I've got a fun little widget that invites users to choose from a list of 114 animals. The UI includes small thumbnails of each species, all the same size (100x70). The sum total of the thumbnails is 2.1M.
I'm not eager to make 114 server requests, so I used ImageMagick to make one VERY long image (11400x70), which comes down to 960K. So the challenge is to chop up that long image into 114 small images on the client. (EDIT: I need each animal as its own image because the UI filters the list down, e.g. "show me only herbivores").
I originally had a convoluted approach where I painted that large image to a canvas after loading a base64 string of the combined image, pulled the ImageData for each animal, painting THAT to a second canvas, and then pulled the dataURL:
...ANSWER
Answered 2019-Jan-09 at 15:19Regarding the memory use, please see this post and this post
So the challenge is to chop up that long image into 114 small images on the client.
What is the need to chop the long image. I would keep it as a single image and use as CSS sprite and show all images.
If your images has fixed dimension a JavaScript loop could render all images in the page. Or you could use a tool like this to get animal position and have it in a css file. But I would prefer the JS loop method.
The code would be something like this
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install css-sprite
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page