Florian Stolzenhain — 2015/10/13
darn!
background-size
.sprite:before {
/* 150x150 */
width: 150px;
height: 150px;
/* x:120 y:850 */
background-position: -120px -850px;
}
.sprite:before {
/* 150x150 */
width: 10em;
height: 10em;
/* x:120 y:850 */
background-position: -8em -56.7em;
/* 1280x2048 */
background-size: 85.3em 136.53em;
font size: 15px;
}
.sprite:before {
/* 150x150 */
width: 8.3333333333em;
height: 8.3333333333em;
/* x:120 y:850 */
background-position: -6.6666666667em -3.15em;
/* 1280x2048 */
background-size: 71.111111111em 113.77777778em;
font size: 18px;
}
$fontSize: 18;
.sprite:before {
/* 150x150 */
width: rem(150);
height: rem(150);
/* x:120 y:850 */
background-position: rem(-120 -850);
/* 1280x2048 */
background-size: rem(1280 2048);
}
transform
which doesn't change the layout flow.background-size
is not supported by IE8, but so are media queries, right?$container: 960;
.sprite:before {
/* 150x150 */
width: (150/$container)*100%;
height: 0;
padding-top: (150/$container)*100%;
/* x:120 y:850 */
background-position: rel(150/$container*100% 150/$container*100%);
/* 1280x2048 */
background-size: rel(1280 2048);
}
.sprite {
/* spritemap size ÷ sprite size × 100% */
background-size: …
/*(sprite offset) ÷ (spritemap size - sprite size) × 100% */
background-position: …
}
.sprite {
/* spritemap size ÷ sprite size × 100% */
background-size: …
/*(sprite offset) ÷ (spritemap size - sprite size) × 100% */
background-position: …
}
… repeat after me:
.sprite-rider:before {
position: relative;
/* 150x150 to 940 */
width: 6.2666666667%;
height: 0;
padding-top: 6.2666666667%;
/* 1280x2048 for 150x150 */
background-size: 853.33333333% 1365.3333333%;
/* x:120 y:850 */
background-position: 0.1061946903% 0.4478398314%;
}
.sprite-rider:before {
position: relative;
/* 150x150 */
width: rel(150,940);
height: 0;
padding-top: rel(150,940);
/* 1280x2048 */
background-size: (1280/150)*100% (2048/150)*100%;
/* x:120 y:850 */
background-position: (120/(1280-150))*100% (850/(2048-150))*100%;
}
.SVGZ
, ImageAlpha)Look up the write-up on my website,
together with Codepen examples.