Re: shorter code with loops(?)

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 UTC