layout/reftests/w3c-css/submitted/flexbox/flexbox-basic-img-horiz-1.xhtml

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <!--
     3      Any copyright is dedicated to the Public Domain.
     4      http://creativecommons.org/publicdomain/zero/1.0/
     5 -->
     6 <!--
     7      This test checks that img elements behave correctly as flex items.
     8 -->
     9 <html xmlns="http://www.w3.org/1999/xhtml">
    10   <head>
    11     <title>CSS Test: Testing flexbox layout algorithm property on img flex items in a horizontal flex container</title>
    12     <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com"/>
    13     <link rel="help" href="http://www.w3.org/TR/css3-flexbox/#layout-algorithm"/>
    14     <link rel="match" href="flexbox-basic-img-horiz-1-ref.xhtml"/>
    15     <style>
    16       div.flexbox {
    17         width: 200px;
    18         background: lightgreen;
    19         display: flex;
    20         justify-content: space-between;
    21         margin-bottom: 5px;
    22         line-height: 8px;
    23       }
    24       img {
    25         min-width: 0;
    26         width: 10px;
    27         height: 20px;
    28         border: 1px dotted green;
    29       }
    30     </style>
    31   </head>
    32   <body>
    34     <!-- A) One flex item -->
    35     <div class="flexbox">
    36       <img src="support/solidblue.png"/>
    37     </div>
    39     <!-- B) Text and an img (ensure they aren't merged into one flex item) -->
    40     <div class="flexbox">
    41       some words <img src="support/solidblue.png"/>
    42     </div>
    44     <!-- C) Two img elements, getting stretched by different ratios, from 0.
    46          Space-to-be-distributed = 200px - borders = 200 - (1 + 1) - (1 + 1)
    47                                  = 196px
    49          1st element gets 5/8 of space: 5/8 * 196px = 122.5px
    50          1st element gets 3/8 of space: 3/8 * 196px = 73.5px
    51       -->
    52     <div class="flexbox">
    53       <img src="support/solidblue.png" style="flex: 5"/>
    54       <img src="support/solidblue.png" style="flex: 3"/>
    55     </div>
    57     <!-- D) Two img elements, getting stretched by different ratios, from
    58          different flex bases.
    60          Space-to-be-distributed = 200px - (33 + 1 + 1) - (13 + 1 + 1) = 150px
    61          1st element gets 2/5 of space: 33px + 2/5 * 150px = 93px
    62          1st element gets 3/5 of space: 13px + 3/5 * 150px = 103px
    63       -->
    64     <div class="flexbox">
    65       <img src="support/solidblue.png" style="width: 33px; flex: 2 auto"/>
    66       <img src="support/solidblue.png" style="width: 13px; flex: 3 auto"/>
    67     </div>
    69     <!-- E) Two flex items, getting shrunk by different amounts.
    71          Space-to-be-distributed = 200px - (150 + 1 + 1) - (100 + 1 + 1) = -54px
    72          First element scaled flex ratio = 4 * 150 = 600
    73          Second element scaled flex ratio = 3 * 100 = 300
    74            * So, total flexibility is 600 + 300 = 900
    76          1st element gets 600/900 of space: 150 + 600/900 * -54 = 114px
    77          2nd element gets 300/900 of space: 100 + 300/900 * -54 = 82px
    78       -->
    79     <div class="flexbox">
    80       <img src="support/solidblue.png" style="width: 150px; flex: 1 4 auto"/>
    81       <img src="support/solidblue.png" style="width: 100px; flex: 1 3 auto"/>
    82     </div>
    84     <!-- F) Making sure we don't grow past max-width -->
    85     <!-- Same as (D), except we've added a max-width on the second element.
    86       -->
    87     <div class="flexbox">
    88       <img src="support/solidblue.png" style="width: 33px; flex: 2 auto"/>
    89       <img src="support/solidblue.png"
    90            style="width: 13px; max-width: 90px; flex: 3 auto"/>
    91     </div>
    93     <!-- G) Making sure we grow at least as large as min-width -->
    94     <!-- Same as (C), except we've added a min-width on the second element.
    95       -->
    96     <div class="flexbox">
    97       <img src="support/solidblue.png" style="width: 33px; flex: 2 auto"/>
    98       <img src="support/solidblue.png"
    99            style="width: 13px; min-width: 150px; flex: 3 auto"/>
   100     </div>
   102   </body>
   103 </html>

mercurial