gecko-dev/layout/reftests/flexbox/flexbox-basic-img-horiz-1.xhtml
Daniel Holbert a3cb31110c Bug 666041: Reftests for css3-flexbox. (tests-only)
--HG--
rename : layout/reftests/bugs/solidblue.png => layout/reftests/flexbox/solidblue.png
2012-09-29 23:42:29 -07:00

100 lines
3.2 KiB
HTML

<?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>
<style>
div.flexbox {
width: 200px;
background: lightgreen;
display: -moz-flex;
-moz-justify-content: space-between;
margin-bottom: 5px;
line-height: 8px;
}
img {
min-width: 0;
width: 10px;
height: 20px;
border: 1px dotted green;
}
</style>
</head>
<body>
<!-- A) One flex item -->
<div class="flexbox">
<img src="solidblue.png"/>
</div>
<!-- B) Text and an img (ensure they aren't merged into one flex item) -->
<div class="flexbox">
some words <img src="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="solidblue.png" style="-moz-flex: 5"/>
<img src="solidblue.png" style="-moz-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="solidblue.png" style="width: 33px; -moz-flex: 2 auto"/>
<img src="solidblue.png" style="width: 13px; -moz-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="solidblue.png" style="width: 150px; -moz-flex: 1 4 auto"/>
<img src="solidblue.png" style="width: 100px; -moz-flex: 1 3 auto"/>
</div>
<!-- F) Making sure we don't grow past max-width -->
<!-- Same as (D), except we've added a max-width on the second element.
-->
<div class="flexbox">
<img src="solidblue.png" style="width: 33px; -moz-flex: 2 auto"/>
<img src="solidblue.png"
style="width: 13px; max-width: 90px; -moz-flex: 3 auto"/>
</div>
<!-- G) Making sure we grow at least as large as min-width -->
<!-- Same as (C), except we've added a min-width on the second element.
-->
<div class="flexbox">
<img src="solidblue.png" style="width: 33px; -moz-flex: 2 auto"/>
<img src="solidblue.png"
style="width: 13px; min-width: 150px; -moz-flex: 3 auto"/>
</div>
</body>
</html>