Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
michael@0 | 2 | <!-- |
michael@0 | 3 | Any copyright is dedicated to the Public Domain. |
michael@0 | 4 | http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 5 | --> |
michael@0 | 6 | <!-- |
michael@0 | 7 | This testcase checks how "min-width" and "max-width" affect the sizing |
michael@0 | 8 | of horizontal flex containers that have no explicit "width" property. |
michael@0 | 9 | --> |
michael@0 | 10 | <html xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 11 | <head> |
michael@0 | 12 | <title>CSS Test: Testing sizing of an auto-sized horizontal flex container with min-width and max-width constraints</title> |
michael@0 | 13 | <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com"/> |
michael@0 | 14 | <link rel="help" href="http://www.w3.org/TR/css3-flexbox/#layout-algorithm"/> |
michael@0 | 15 | <link rel="match" href="flexbox-sizing-horiz-1-ref.xhtml"/> |
michael@0 | 16 | <style> |
michael@0 | 17 | div { height: 10px; } |
michael@0 | 18 | div.flexbox { |
michael@0 | 19 | border: 1px dashed blue; |
michael@0 | 20 | font-size: 10px; |
michael@0 | 21 | display: flex; |
michael@0 | 22 | margin-bottom: 2px; |
michael@0 | 23 | } |
michael@0 | 24 | div.a { |
michael@0 | 25 | flex: 1 20px; |
michael@0 | 26 | max-width: 60px; |
michael@0 | 27 | background: lightgreen; |
michael@0 | 28 | } |
michael@0 | 29 | div.b { |
michael@0 | 30 | flex: 1 20px; |
michael@0 | 31 | min-width: 40px; |
michael@0 | 32 | max-width: 60px; |
michael@0 | 33 | background: purple; |
michael@0 | 34 | } |
michael@0 | 35 | div.c { |
michael@0 | 36 | flex: 1 40px; |
michael@0 | 37 | min-width: 10px; |
michael@0 | 38 | max-width: 60px; |
michael@0 | 39 | background: orange; |
michael@0 | 40 | } |
michael@0 | 41 | </style> |
michael@0 | 42 | </head> |
michael@0 | 43 | <body> |
michael@0 | 44 | <!-- auto-sized horizontal flexbox should occupy the available width. --> |
michael@0 | 45 | <div class="flexbox"> |
michael@0 | 46 | <div class="a"/><div class="b"/><div class="c"/> |
michael@0 | 47 | </div> |
michael@0 | 48 | |
michael@0 | 49 | <!-- Adding a small min-size shouldn't affect that. --> |
michael@0 | 50 | <div class="flexbox" style="min-width: 10px"> |
michael@0 | 51 | <div class="a"/><div class="b"/><div class="c"/> |
michael@0 | 52 | </div> |
michael@0 | 53 | |
michael@0 | 54 | <!-- ...but a (large) max-size will limit us to that size, instead of |
michael@0 | 55 | our available size.--> |
michael@0 | 56 | <div class="flexbox" style="max-width: 300px"> |
michael@0 | 57 | <div class="a"/><div class="b"/><div class="c"/> |
michael@0 | 58 | </div> |
michael@0 | 59 | |
michael@0 | 60 | <!-- If we set a maximum size that's even smaller, it'll limit our |
michael@0 | 61 | size and compress our children. --> |
michael@0 | 62 | <div class="flexbox" style="max-width: 70px"> |
michael@0 | 63 | <div class="a"/><div class="b"/><div class="c"/> |
michael@0 | 64 | </div> |
michael@0 | 65 | |
michael@0 | 66 | <!-- The max-size may be small enough that our items will overflow. --> |
michael@0 | 67 | <div class="flexbox" style="max-width: 20px"> |
michael@0 | 68 | <div class="a"/><div class="b"/><div class="c"/> |
michael@0 | 69 | </div> |
michael@0 | 70 | |
michael@0 | 71 | <!-- But if we add a min-size, it beats the max-size. Here, we use a |
michael@0 | 72 | min-size smaller than the sum of the items' base sizes... --> |
michael@0 | 73 | <div class="flexbox" style="min-width: 58px; max-width: 20px"> |
michael@0 | 74 | <div class="a"/><div class="b"/><div class="c"/> |
michael@0 | 75 | </div> |
michael@0 | 76 | |
michael@0 | 77 | <!-- ...and here we use a min-size larger than the sum of the items' |
michael@0 | 78 | base sizes. --> |
michael@0 | 79 | <div class="flexbox" style="min-width: 140px; max-width: 20px"> |
michael@0 | 80 | <div class="a"/><div class="b"/><div class="c"/> |
michael@0 | 81 | </div> |
michael@0 | 82 | |
michael@0 | 83 | </body> |
michael@0 | 84 | </html> |