Re: [css3-background] New use case for background-position-x (&y!)

On Mon, Nov 8, 2010 at 5:57 AM, Lee Kowalkowski
<lee.kowalkowski@googlemail.com> wrote:
> On 08/11/2010, fantasai <fantasai.lists@inkedblade.net> wrote:
>> On 11/08/2010 01:36 AM, Lee Kowalkowski wrote:
>>> Hi,
>>> I give my playing card elements class names like "diamonds rank-10", I
>>> want to apply background-y depending on suit and background-x
>>> depending on rank, using _different_ class names.
>
>> All the use cases I've seen so far are improved hacks for image
>> sprites. Which is something I think should be addressed directly,
>> not by making such hacks easier. IMO.
>
> You're dismissing this technique as a hack?  Do you have any
> justification for that?  I don't understand, is there a technique that
> you consider to be a non-hack for image sprites?  Or are you
> suggesting that all image sprites are hacks and therefore not worthy
> of consideration?
>
> How would it be addressed directly?  Please elaborate.

All image spriting techniques used today are hacks, yes.  They're a
workaround for the fact that network requests have a significant
constant cost, so it's more efficient to make a single large request
rather than multiple small requests.

This is something that should be fixed on the network level, and
people have been working for a while on fixing this.  For example,
some Moz people introduced the idea of resource packages (putting lots
of resources into a single zip, which can then be conveniently linked
into), while Google is working on its SPDY networking protocol (if I
understand correctly, basically an improved version of request
pipelining).

The specific spriting technique of using background-position is an
extra hack on top of the basic hack.  It only works for background
images, not any other image (list-style-image, border-image, the <img>
element, etc.), and only works if the sprites are all the same size.
The Media Fragments spec will, when implemented, offer a proper way to
reference sprites from an image that works *anywhere*.

> >From my perspective, background-position is a shorthand property
> without its individual counterparts, this is bizarre, they should be
> there for completeness.
>
> They way I'm currently seeing it, the "hack" is having to specify 52
> rules, where I only want 17.

This doesn't make sense - the word "hack" is in no way applicable to
this point.  You are trying to assign 52 different backgrounds to 52
different types of elements.  Thus, it makes sense that this requires
52 different rules.

The fact that you can organize the images in such a way that they can
potentially be referenced with a combination of 17 rules doesn't make
the 52-rule version a hack.  For example, if you had images for each
of the old web-safe colors, these could potentially be organized into
a 6x6x6 cube and referenced with only 18 rules.  Does this make
background-position a hack, since its 2-dimensional nature means you'd
have to use 42 rules?

~TJ

Received on Monday, 8 November 2010 17:50:24 UTC