1<!-- 2@license 3Copyright (c) 2015 The Polymer Project Authors. All rights reserved. 4This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7Code distributed by Google as part of the polymer project is also 8subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9--> 10 11<link rel="import" href="../polymer/polymer.html"> 12 13<!-- 14The `<iron-flex-layout>` component provides simple ways to use 15[CSS flexible box layout](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes), 16also known as flexbox. This component provides two different ways to use flexbox: 17 181. [Layout classes](https://github.com/PolymerElements/iron-flex-layout/tree/master/iron-flex-layout-classes.html). 19The layout class stylesheet provides a simple set of class-based flexbox rules, that 20let you specify layout properties directly in markup. You must include this file 21in every element that needs to use them. 22 23 Sample use: 24 25 ``` 26 <custom-element-demo> 27 <template> 28 <script src="../webcomponentsjs/webcomponents-lite.js"></script> 29 <next-code-block></next-code-block> 30 </template> 31 </custom-element-demo> 32 ``` 33 34 ```html 35 <link rel="import" href="iron-flex-layout-classes.html"> 36 <style is="custom-style" include="iron-flex iron-flex-alignment"></style> 37 <style> 38 .test { width: 100px; } 39 </style> 40 <div class="layout horizontal center-center"> 41 <div class="test">horizontal layout center alignment</div> 42 </div> 43 ``` 44 452. [Custom CSS mixins](https://github.com/PolymerElements/iron-flex-layout/blob/master/iron-flex-layout.html). 46The mixin stylesheet includes custom CSS mixins that can be applied inside a CSS rule using the `@apply` function. 47 48Please note that the old [/deep/ layout classes](https://github.com/PolymerElements/iron-flex-layout/tree/master/classes) 49are deprecated, and should not be used. To continue using layout properties 50directly in markup, please switch to using the new `dom-module`-based 51[layout classes](https://github.com/PolymerElements/iron-flex-layout/tree/master/iron-flex-layout-classes.html). 52Please note that the new version does not use `/deep/`, and therefore requires you 53to import the `dom-modules` in every element that needs to use them. 54 55A complete [guide](https://elements.polymer-project.org/guides/flex-layout) to `<iron-flex-layout>` is available. 56 57@group Iron Elements 58@pseudoElement iron-flex-layout 59@demo demo/index.html 60--> 61 62<style> 63 /* IE 10 support for HTML5 hidden attr */ 64 [hidden] { 65 display: none !important; 66 } 67</style> 68 69<style is="custom-style"> 70 :root { 71 72 --layout: { 73 display: -ms-flexbox; 74 display: -webkit-flex; 75 display: flex; 76 }; 77 78 --layout-inline: { 79 display: -ms-inline-flexbox; 80 display: -webkit-inline-flex; 81 display: inline-flex; 82 }; 83 84 --layout-horizontal: { 85 @apply(--layout); 86 87 -ms-flex-direction: row; 88 -webkit-flex-direction: row; 89 flex-direction: row; 90 }; 91 92 --layout-horizontal-reverse: { 93 @apply(--layout); 94 95 -ms-flex-direction: row-reverse; 96 -webkit-flex-direction: row-reverse; 97 flex-direction: row-reverse; 98 }; 99 100 --layout-vertical: { 101 @apply(--layout); 102 103 -ms-flex-direction: column; 104 -webkit-flex-direction: column; 105 flex-direction: column; 106 }; 107 108 --layout-vertical-reverse: { 109 @apply(--layout); 110 111 -ms-flex-direction: column-reverse; 112 -webkit-flex-direction: column-reverse; 113 flex-direction: column-reverse; 114 }; 115 116 --layout-wrap: { 117 -ms-flex-wrap: wrap; 118 -webkit-flex-wrap: wrap; 119 flex-wrap: wrap; 120 }; 121 122 --layout-no-wrap: { 123 -ms-flex-wrap: nowrap; 124 -webkit-flex-wrap: nowrap; 125 flex-wrap: nowrap; 126 }; 127 128 --layout-wrap-reverse: { 129 -ms-flex-wrap: wrap-reverse; 130 -webkit-flex-wrap: wrap-reverse; 131 flex-wrap: wrap-reverse; 132 }; 133 134 --layout-flex-auto: { 135 -ms-flex: 1 1 auto; 136 -webkit-flex: 1 1 auto; 137 flex: 1 1 auto; 138 }; 139 140 --layout-flex-none: { 141 -ms-flex: none; 142 -webkit-flex: none; 143 flex: none; 144 }; 145 146 --layout-flex: { 147 -ms-flex: 1 1 0.000000001px; 148 -webkit-flex: 1; 149 flex: 1; 150 -webkit-flex-basis: 0.000000001px; 151 flex-basis: 0.000000001px; 152 }; 153 154 --layout-flex-2: { 155 -ms-flex: 2; 156 -webkit-flex: 2; 157 flex: 2; 158 }; 159 160 --layout-flex-3: { 161 -ms-flex: 3; 162 -webkit-flex: 3; 163 flex: 3; 164 }; 165 166 --layout-flex-4: { 167 -ms-flex: 4; 168 -webkit-flex: 4; 169 flex: 4; 170 }; 171 172 --layout-flex-5: { 173 -ms-flex: 5; 174 -webkit-flex: 5; 175 flex: 5; 176 }; 177 178 --layout-flex-6: { 179 -ms-flex: 6; 180 -webkit-flex: 6; 181 flex: 6; 182 }; 183 184 --layout-flex-7: { 185 -ms-flex: 7; 186 -webkit-flex: 7; 187 flex: 7; 188 }; 189 190 --layout-flex-8: { 191 -ms-flex: 8; 192 -webkit-flex: 8; 193 flex: 8; 194 }; 195 196 --layout-flex-9: { 197 -ms-flex: 9; 198 -webkit-flex: 9; 199 flex: 9; 200 }; 201 202 --layout-flex-10: { 203 -ms-flex: 10; 204 -webkit-flex: 10; 205 flex: 10; 206 }; 207 208 --layout-flex-11: { 209 -ms-flex: 11; 210 -webkit-flex: 11; 211 flex: 11; 212 }; 213 214 --layout-flex-12: { 215 -ms-flex: 12; 216 -webkit-flex: 12; 217 flex: 12; 218 }; 219 220 /* alignment in cross axis */ 221 222 --layout-start: { 223 -ms-flex-align: start; 224 -webkit-align-items: flex-start; 225 align-items: flex-start; 226 }; 227 228 --layout-center: { 229 -ms-flex-align: center; 230 -webkit-align-items: center; 231 align-items: center; 232 }; 233 234 --layout-end: { 235 -ms-flex-align: end; 236 -webkit-align-items: flex-end; 237 align-items: flex-end; 238 }; 239 240 --layout-baseline: { 241 -ms-flex-align: baseline; 242 -webkit-align-items: baseline; 243 align-items: baseline; 244 }; 245 246 /* alignment in main axis */ 247 248 --layout-start-justified: { 249 -ms-flex-pack: start; 250 -webkit-justify-content: flex-start; 251 justify-content: flex-start; 252 }; 253 254 --layout-center-justified: { 255 -ms-flex-pack: center; 256 -webkit-justify-content: center; 257 justify-content: center; 258 }; 259 260 --layout-end-justified: { 261 -ms-flex-pack: end; 262 -webkit-justify-content: flex-end; 263 justify-content: flex-end; 264 }; 265 266 --layout-around-justified: { 267 -ms-flex-pack: distribute; 268 -webkit-justify-content: space-around; 269 justify-content: space-around; 270 }; 271 272 --layout-justified: { 273 -ms-flex-pack: justify; 274 -webkit-justify-content: space-between; 275 justify-content: space-between; 276 }; 277 278 --layout-center-center: { 279 @apply(--layout-center); 280 @apply(--layout-center-justified); 281 }; 282 283 /* self alignment */ 284 285 --layout-self-start: { 286 -ms-align-self: flex-start; 287 -webkit-align-self: flex-start; 288 align-self: flex-start; 289 }; 290 291 --layout-self-center: { 292 -ms-align-self: center; 293 -webkit-align-self: center; 294 align-self: center; 295 }; 296 297 --layout-self-end: { 298 -ms-align-self: flex-end; 299 -webkit-align-self: flex-end; 300 align-self: flex-end; 301 }; 302 303 --layout-self-stretch: { 304 -ms-align-self: stretch; 305 -webkit-align-self: stretch; 306 align-self: stretch; 307 }; 308 309 --layout-self-baseline: { 310 -ms-align-self: baseline; 311 -webkit-align-self: baseline; 312 align-self: baseline; 313 }; 314 315 /* multi-line alignment in main axis */ 316 317 --layout-start-aligned: { 318 -ms-flex-line-pack: start; /* IE10 */ 319 -ms-align-content: flex-start; 320 -webkit-align-content: flex-start; 321 align-content: flex-start; 322 }; 323 324 --layout-end-aligned: { 325 -ms-flex-line-pack: end; /* IE10 */ 326 -ms-align-content: flex-end; 327 -webkit-align-content: flex-end; 328 align-content: flex-end; 329 }; 330 331 --layout-center-aligned: { 332 -ms-flex-line-pack: center; /* IE10 */ 333 -ms-align-content: center; 334 -webkit-align-content: center; 335 align-content: center; 336 }; 337 338 --layout-between-aligned: { 339 -ms-flex-line-pack: justify; /* IE10 */ 340 -ms-align-content: space-between; 341 -webkit-align-content: space-between; 342 align-content: space-between; 343 }; 344 345 --layout-around-aligned: { 346 -ms-flex-line-pack: distribute; /* IE10 */ 347 -ms-align-content: space-around; 348 -webkit-align-content: space-around; 349 align-content: space-around; 350 }; 351 352 /******************************* 353 Other Layout 354 *******************************/ 355 356 --layout-block: { 357 display: block; 358 }; 359 360 --layout-invisible: { 361 visibility: hidden !important; 362 }; 363 364 --layout-relative: { 365 position: relative; 366 }; 367 368 --layout-fit: { 369 position: absolute; 370 top: 0; 371 right: 0; 372 bottom: 0; 373 left: 0; 374 }; 375 376 --layout-scroll: { 377 -webkit-overflow-scrolling: touch; 378 overflow: auto; 379 }; 380 381 --layout-fullbleed: { 382 margin: 0; 383 height: 100vh; 384 }; 385 386 /* fixed position */ 387 388 --layout-fixed-top: { 389 position: fixed; 390 top: 0; 391 left: 0; 392 right: 0; 393 }; 394 395 --layout-fixed-right: { 396 position: fixed; 397 top: 0; 398 right: 0; 399 bottom: 0; 400 }; 401 402 --layout-fixed-bottom: { 403 position: fixed; 404 right: 0; 405 bottom: 0; 406 left: 0; 407 }; 408 409 --layout-fixed-left: { 410 position: fixed; 411 top: 0; 412 bottom: 0; 413 left: 0; 414 }; 415 416 } 417 418</style> 419