W3C home > Mailing lists > Public > www-style@w3.org > June 2014

Re: Background image cropping

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Mon, 9 Jun 2014 13:26:44 -0700
Message-ID: <CAAWBYDDK+z1QkTL6LYKWKS8Q49dxE4j74O=q2+UYJU+rzWnYGA@mail.gmail.com>
To: Lajos Koszti <ajnasz@ajnasz.hu>
Cc: www-style list <www-style@w3.org>
On Mon, Jun 9, 2014 at 2:27 AM, Lajos Koszti <ajnasz@ajnasz.hu> wrote:
> Hi,
>
> I have an idea which could be useful for everyone.
>
> Image sprites are pretty popular these days, where you add several
> images to one image set as as a background image and crop it by
> setting a fixed size of the element and moving the background image
> behind it. Using the ::after and ::before you don't even need the
> extra element into the HTML code.
> However it's a hackish thing. You may want to use the ::after and
> ::before selectors for other purpose or you would need an icon from a
> sprite for an element, where you can not use the ::after or ::before
> like inputs.
>
> So, a great solution would be to be able to define the area which is
> visible from a background image. That would make possible to not add
> extra elements from the DOM just to crop a background image, use
> pseudo-elements to other then cropping an image and also we would be
> able to use sprite with any element which can have a background image.
>
> What do you think?

This is already possible per spec, by using Media Fragments.  See
<http://dev.w3.org/csswg/css-images/#image-fragments> for an example.
However, no browser implements Media Fragments yet.

~TJ
Received on Monday, 9 June 2014 20:27:31 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:22 UTC