[Bug 29238] New: There's no way to size a background to always fill or always fit (while maintaining aspect ratio)

https://www.w3.org/Bugs/Public/show_bug.cgi?id=29238

            Bug ID: 29238
           Summary: There's no way to size a background to always fill or
                    always fit (while maintaining aspect ratio)
           Product: CSS
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: critical
          Priority: P2
         Component: Backgrounds and Borders
          Assignee: fantasai.bugs@inkedblade.net
          Reporter: teo8976@gmail.com
        QA Contact: public-css-bugzilla@w3.org
  Target Milestone: ---

With background-image (and background-repeat: no-repeat), you can have a given
dimention of the bg image match the same dimention of the container, and the
other dimention computed automatically according to the image aspect ration.
That is, you can do:

  background-size: 100% auto;

or

  background-size: auto 100%;

However, if you don't know in advance whether the aspect ratio of the image is
wider or narrower than that of the container, you can 
NEITHER:
- obtain the minimum size that completely fills the container while maintaining
the image's aspect ratio (hence having one and only one of the dimensions
cropped), that is, obtain the maximum scale factor between matching the width
and matching the height
NOR:
- have the image at the maximum size that fits completely in the container
matching whichever dimension restricts it the most (hence leaving empty space
in one and only one dimension), that is, obtain the minimum scale factor
between matching the width and matching the height.

These are super basic needs and it's unbelievable that there's no way to
achieve them with any combination of background-size and background-position.

Having to program this in JavaScript is totally ridiculous.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Saturday, 24 October 2015 23:36:45 UTC