Re: [css-background] "background-repeat:round;" and aspect ratio

On Fri, Jul 16, 2010 at 4:00 PM, Brian Manthos <brianman@microsoft.com> wrote:
>> Are you willing to specify an explicit size for the image?  If so, then it's
>> relatively easy - just use repeat:space rather than round.
>
> For the purposes of the general example, no.
>
> The idea is that you make a page, author a rule, and use an arbitrary image on an arbitrarily sized element and it should "just work".
>
> Are you saying that this use case isn't directly representable in CSS3?
>
> That was the conclusion I had been leaning toward, but I wanted another opinion.

It all depends on what you want.  If you're okay with it not tiling,
just use background-size:contain and background-position:center.
That'll give you a single copy of the image, sized as large as
possible without clipping, and centered.  That's fine for a very large
image, but not great for images that may be smaller than the element.

There are some cases that can't be covered automatically, but probably
less than you're thinking.

~TJ

Received on Friday, 16 July 2010 23:09:49 UTC