layout/reftests/w3c-css/submitted/flexbox/flexbox-basic-img-vert-1.xhtml
author Daniel Holbert <dholbert@cs.stanford.edu>
Thu, 06 Jun 2013 20:37:18 -0700
changeset 145816 98b4083befbbf8a05ad783a8a0eab69e36531cf8
parent 145815 8e82f9384070dcd9f26135723e6155110e2b0cb1
child 145817 dd81ecba7afdf66837f2a6e0fe8667fa498a529f
permissions -rw-r--r--
Bug 880137 part 3: Give w3c-css flexbox reftests the necessary boilerplate headers with author info, reference, and placeholder test-title and "help" nodes (populated in next patch). rs=dbaron

<?xml version="1.0" encoding="UTF-8"?>
<!--
     Any copyright is dedicated to the Public Domain.
     http://creativecommons.org/publicdomain/zero/1.0/
-->
<!--
     This test checks that img elements behave correctly as flex items.
-->
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>CSS Test: {TODO: INSERT TITLE}</title>
    <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com"/>
    <link rel="help" href="http://dev.w3.org/csswg/css-flexbox/"/>
    <link rel="match" href="flexbox-basic-img-vert-1-ref.xhtml"/>
    <style>
      div.flexbox {
        height: 200px;
        background: lightgreen;
        display: flex;
        justify-content: space-between;
        flex-direction: column;
        float: left;
        margin-right: 10px;
        font: 8px monospace;
      }
      img {
        width: 20px;
        height: 10px;
        min-height: 0;
        border: 1px dotted green;
      }
    </style>
  </head>
  <body>

    <!-- A) One flex item -->
    <div class="flexbox">
      <img src="support/solidblue.png"/>
    </div>

    <!-- B) Text and an img (ensure they aren't merged into one flex item) -->
    <div class="flexbox">
      a b <img src="support/solidblue.png"/>
    </div>

    <!-- C) Two img elements, getting stretched by different ratios, from 0.

         Space-to-be-distributed = 200px - borders = 200 - (1 + 1) - (1 + 1)
                                 = 196px

         1st element gets 5/8 of space: 5/8 * 196px = 122.5px
         1st element gets 3/8 of space: 3/8 * 196px = 73.5px
      -->
    <div class="flexbox">
      <img src="support/solidblue.png" style="flex: 5"/>
      <img src="support/solidblue.png" style="flex: 3"/>
    </div>

    <!-- D) Two img elements, getting stretched by different ratios, from
         different flex bases.

         Space-to-be-distributed = 200px - (33 + 1 + 1) - (13 + 1 + 1) = 150px
         1st element gets 2/5 of space: 33px + 2/5 * 150px = 93px
         1st element gets 3/5 of space: 13px + 3/5 * 150px = 103px
      -->
    <div class="flexbox">
      <img src="support/solidblue.png" style="height: 33px; flex: 2 auto"/>
      <img src="support/solidblue.png" style="height: 13px; flex: 3 auto"/>
    </div>

    <!-- E) Two flex items, getting shrunk by different amounts.

         Space-to-be-distributed = 200px - (150 + 1 + 1) - (100 + 1 + 1) = -54px
         First element scaled flex ratio = 4 * 150 = 600
         Second element scaled flex ratio = 3 * 100 = 300
           * So, total flexibility is 600 + 300 = 900

         1st element gets 600/900 of space: 150 + 600/900 * -54 = 114px
         2nd element gets 300/900 of space: 100 + 300/900 * -54 = 82px
      -->
    <div class="flexbox">
      <img src="support/solidblue.png" style="height: 150px; flex: 1 4 auto"/>
      <img src="support/solidblue.png" style="height: 100px; flex: 1 3 auto"/>
    </div>

    <!-- F) Making sure we don't grow past max-height -->
    <!-- Same as (D), except we've added a max-height on the second element.
      -->
    <div class="flexbox">
      <img src="support/solidblue.png" style="height: 33px; flex: 2 auto"/>
      <img src="support/solidblue.png"
           style="height: 13px; max-height: 90px; flex: 3 auto"/>
    </div>

    <!-- G) Making sure we grow at least as large as min-height -->
    <!-- Same as (C), except we've added a min-height on the second element.
      -->
    <div class="flexbox">
      <img src="support/solidblue.png" style="height: 33px; flex: 2 auto"/>
      <img src="support/solidblue.png"
           style="height: 13px; min-height: 150px; flex: 3 auto"/>
    </div>

  </body>
</html>