<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>29238</bug_id>
          
          <creation_ts>2015-10-24 23:36:43 +0000</creation_ts>
          <short_desc>There&apos;s no way to size a background to always fill or always fit (while maintaining aspect ratio)</short_desc>
          <delta_ts>2015-10-24 23:36:43 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>CSS</product>
          <component>Backgrounds and Borders</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>critical</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>teo8976</reporter>
          <assigned_to name="fantasai">fantasai.bugs</assigned_to>
          
          
          <qa_contact>public-css-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>123894</commentid>
    <comment_count>0</comment_count>
    <who name="">teo8976</who>
    <bug_when>2015-10-24 23:36:43 +0000</bug_when>
    <thetext>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&apos;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&apos;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&apos;s unbelievable that there&apos;s no way to achieve them with any combination of background-size and background-position.

Having to program this in JavaScript is totally ridiculous.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>