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

Re: Background image cropping

From: Dirk Schulze <dschulze@adobe.com>
Date: Tue, 10 Jun 2014 14:40:32 +0000
To: Tab Atkins Jr. <jackalmage@gmail.com>
CC: Lajos Koszti <ajnasz@ajnasz.hu>, www-style list <www-style@w3.org>
Message-ID: <EDBEBD39-A147-4EC0-9274-830991CF265B@adobe.com>
I believe Mozilla has a -moz-image-rect() [1] image function that clips the input image argument. It is not specified though.

Dirk

[1] https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-image-rect


> On Jun 9, 2014, at 10:30 PM, "Tab Atkins Jr." <jackalmage@gmail.com> wrote:
> 
>> 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 Tuesday, 10 June 2014 14:41:06 UTC

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