W3C home > Mailing lists > Public > www-style@w3.org > December 2009

Re: shorter code with loops(?)

From: Aryeh Gregor <Simetrical+w3c@gmail.com>
Date: Wed, 23 Dec 2009 19:51:02 -0500
Message-ID: <7c2a12e20912231651g6359a742i4b8fc67d88f7a353@mail.gmail.com>
To: asaf@freeallweb.org
Cc: www-style list <www-style@w3.org>
On Wed, Dec 23, 2009 at 3:44 AM, Asaf Chertkoff <asaf@freeallweb.org> wrote:
> #$value=[ff-title,building-title,...,cloud-title] {
> margin:20px 10x 0 0;
> float: right;
> color: red;
> background:url("images/'$value'.png") 0 0 no-repeat;
> }

Well, for starters, you can do

#ff-title, #building-title, ..., #cloud-title {
    margin: 20px 10px 0 0;
    float: right;
    color: red;
    background: 0 0 no-repeat;
}
#ff-title { background-image: url(images/ff-title.png); }
#building-title { background-image: url(images/building-title.png); }
...
#cloud-title { background-image: url(images/cloud-title.png); }

That will save you some bytes.  But no, there's no way to do this more
programmatically right now.  The most obvious direction to go in would
be something like url(images/attr(id).png), with some magic to make
that work.  Maybe concat("images/", attr(id), ".png") or whatever.
For now, it's easily solved with copy-pasting or server-side script.
Received on Thursday, 24 December 2009 00:51:30 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 22 May 2012 03:47:12 GMT