Note that there are some explanatory texts on larger screens.

plurals
  1. POCSS3 background-image with bundled sprite image based on images with different original Image Size
    primarykey
    data
    text
    <p>Hello I am currently writing a sprite generator based on CSS 3 and my question is : What is the best practice to show CSS3 background-images with a bundled sprite image based on images with different original Image Size concatenated vertical?</p> <p>I have tried this here at <a href="http://jsfiddle.net/s__a/xcZ4j/" rel="nofollow">jsfiddle</a>, </p> <pre><code>.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; } </code></pre> <p>but this technique does only work if all images have the same image size. So in example the second image should have 32px height. I have worked out compromise solutions at <a href="http://jsfiddle.net/s__a/xcZ4j/" rel="nofollow">jsfiddle</a> </p> <p><em>1. via extra HTML markup</em>, but I think it is ugly and I m wondering if there is not a full CSS integration possbile to make css background-image realy usable.</p> <p><em>2. via calculation</em></p> <pre><code>.gui-background-brand-grayscale-nodejs-32 { width: 119px; height: 32px; background-size: 238px; background-position: 0 -64px; } </code></pre> <p>currently I calculating factors</p> <pre><code>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; </code></pre> <p>I wish the css could be defined with the width and height values ​​of the original images because factor X can result in a decimal value. Not easy!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload