CSS3 background-image with bundled sprite image based on images with different original Image Size -
hello writing sprite generator based on css 3 , question : best practice show css3 background-images bundled sprite image based on images different original image size concatenated vertical?
i have tried here @ jsfiddle,
.gui-background-brand-nodejs-64, .gui-background-brand-grayscale-nodejs-32{ background-image: url("http://www.shareimages.com/images/pics/0/0/3/65385-rjwwm5wfk6ainac-sprite.png"); background-repeat: no-repeat; display: inline-block; background-size: 100%; } .gui-background-brand-nodejs-64{ width: 238px; height: 64px; background-position:0 0px; } .gui-background-brand-grayscale-nodejs-32{ width: 119px; height: 32px; background-position:0 -32px; } but technique work if images have same image size. in example second image should have 32px height. have worked out compromise solutions @ jsfiddle
1. via html markup, think ugly , m wondering if there not full css integration possbile make css background-image realy usable.
2. via calculation
.gui-background-brand-grayscale-nodejs-32 { width: 119px; height: 32px; background-size: 238px; background-position: 0 -64px; } currently calculating factors
x = (longest image width / current image width) y = sum(previous original image heights) background-size: {current image width*x}px; background-position: 0 -{y}px; i wish css defined width , height values of original images because factor x can result in decimal value. not easy!
ok . far nobody answered decided choose answer 2. via calculation! ve created image processing service web development handles stuff automaticaly @ https://github.com/s-a/scream-js if interested.
Comments
Post a Comment