08-13-responsive-flexbox-widget.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Responsive flexbox widget, without media queries.</title>
  6. <style>
  7. .ordering-widget {
  8. list-style: none;
  9. margin: 0;
  10. padding: 0;
  11. font-family: 'Avenir Next', Avenir, SegoeUI, sans-serif;
  12. }
  13. .ordering-widget * {
  14. -moz-box-sizing: border-box;
  15. box-sizing: border-box;
  16. }
  17. /**
  18. * bug fix for IE10-11, which doesn't apply flexbox styling to
  19. * elements that are not displayed as blocks by default. Since our
  20. * elements are mostly span:s, we need to set the to display as block
  21. * *before* turning them into flexbox items.
  22. */
  23. .item-name,
  24. .item-controls,
  25. .item-decrease,
  26. .item-increase {
  27. display: block;
  28. }
  29. .item {
  30. color: #fff;
  31. background-color: #129490;
  32. display: -webkit-flex;
  33. display: -ms-flexbox;
  34. display: flex;
  35. -webkit-flex-wrap: wrap;
  36. -ms-flex-wrap: wrap;
  37. flex-wrap: wrap;
  38. font-size: 1.5em;
  39. padding: 0;
  40. margin-bottom: .25em;
  41. }
  42. .item-name {
  43. padding: .25em;
  44. -webkit-flex: 1 0 13em;
  45. -ms-flex: 1 0 13em;
  46. flex: 1 0 13em;
  47. }
  48. .item-controls {
  49. -webkit-flex: 1 0 4em;
  50. -ms-flex: 1 0 4em;
  51. flex: 1 0 4em;
  52. display: -webkit-flex;
  53. display: -ms-flexbox;
  54. display: flex;
  55. }
  56. .item-control {
  57. -webkit-flex: 1;
  58. -ms-flex: 1;
  59. flex: 1;
  60. text-align: center;
  61. padding: .25em;
  62. cursor: pointer;
  63. width: 100%;
  64. margin: 0;
  65. border: 0;
  66. color: #fff;
  67. font-size: inherit;
  68. }
  69. .item-increase {
  70. background-color: #1e6f6d;
  71. }
  72. .item-decrease {
  73. background-color: #1c5453;
  74. }
  75. </style>
  76. </head>
  77. <body>
  78. <ul class="ordering-widget">
  79. <li class="item">
  80. <span class="item-name">Flux capacitor regulator</span>
  81. <span class="item-controls">
  82. <button class="item-control item-increase" aria-label="Increase">+</button>
  83. <button class="item-control item-decrease" aria-label="Decrease">-</button>
  84. </span>
  85. </li>
  86. <li class="item">
  87. <span class="item-name">Multiverse unicorn wrench</span>
  88. <span class="item-controls">
  89. <button class="item-control item-increase" aria-label="Increase">+</button>
  90. <button class="item-control item-decrease" aria-label="Decrease">-</button>
  91. </span>
  92. </li>
  93. <li class="item">
  94. <span class="item-name">Singularity transmogrifier</span>
  95. <span class="item-controls">
  96. <button class="item-control item-increase" aria-label="Increase">+</button>
  97. <button class="item-control item-decrease" aria-label="Decrease">-</button>
  98. </span>
  99. </li>
  100. <li class="item">
  101. <span class="item-name">Time-reverse sensitive oil</span>
  102. <span class="item-controls">
  103. <button class="item-control item-increase" aria-label="Increase">+</button>
  104. <button class="item-control item-decrease" aria-label="Decrease">-</button>
  105. </span>
  106. </li>
  107. </ul>
  108. </body>
  109. </html>