image.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. ---
  2. title: Image
  3. layout: documentation
  4. doc-tab: elements
  5. doc-subtab: image
  6. dimensions:
  7. - 16
  8. - 24
  9. - 32
  10. - 48
  11. - 64
  12. - 96
  13. - 128
  14. breadcrumb:
  15. - home
  16. - documentation
  17. - elements
  18. - elements-image
  19. meta:
  20. colors: false
  21. sizes: false
  22. variables: true
  23. ---
  24. {% capture image %}
  25. <figure class="image is-128x128">
  26. <img src="{{site.url}}/images/placeholders/128x128.png">
  27. </figure>
  28. {% endcapture %}
  29. {% capture retina_image %}
  30. <figure class="image is-128x128">
  31. <img src="{{site.url}}/images/placeholders/256x256.png">
  32. </figure>
  33. {% endcapture %}
  34. <div class="content">
  35. <p>Because images can take a few seconds to load (or not at all), use the <code>.image</code> container to specify a <strong>precisely sized</strong> container so that your layout isn't broken because of image loading or image errors.</p>
  36. </div>
  37. {% include elements/snippet.html content=image %}
  38. {% include elements/anchor.html name="Fixed square images" %}
  39. <div class="content">
  40. <p>There are <strong>7</strong> dimensions to choose from, useful for <strong>avatars</strong>:</p>
  41. </div>
  42. <table class="table is-bordered">
  43. <tbody>
  44. {% for dimension in page.dimensions %}
  45. <tr>
  46. <td><code>image is-{{ dimension }}x{{ dimension }}</code></td>
  47. <td><figure class="image is-{{ dimension }}x{{ dimension }}"><img src="{{site.url}}/images/placeholders/{{ dimension }}x{{ dimension }}.png"></figure></td>
  48. <td>{{ dimension }}x{{ dimension }}px</td>
  49. </tr>
  50. {% endfor %}
  51. </tbody>
  52. </table>
  53. {% include elements/anchor.html name="Retina images" %}
  54. <div class="content">
  55. <p>Because the image is fixed in size, you can use an image that is <strong>twice as big</strong>. So for example, in a <code>128x128</code> container, you can use a <code>256x256</code> image, but resized to <strong>128x128</strong> pixels.</p>
  56. </div>
  57. {% include elements/snippet.html content=retina_image %}
  58. {% include elements/anchor.html name="Responsive images with ratios" %}
  59. <div class="content">
  60. <p>If you don't know the exact dimensions but know the <strong>ratio</strong> instead, you can use one of the <strong>16 ratio modifiers</strong>, which include [common aspect ratios in still photography](https://en.wikipedia.org/wiki/Aspect_ratio_(image)#Still_photography):</p>
  61. </div>
  62. <table id="images" class="table is-bordered">
  63. <tbody>
  64. <tr>
  65. <td><code>image is-square</code></td>
  66. <td><figure class="image is-square"><img src="{{site.url}}/images/placeholders/480x480.png"></figure></td>
  67. <td>Square (or 1 by 1)</td>
  68. </tr>
  69. <tr>
  70. <td><code>image is-1by1</code></td>
  71. <td><figure class="image is-1by1"><img src="{{site.url}}/images/placeholders/480x480.png"></figure></td>
  72. <td>1 by 1</td>
  73. </tr>
  74. <tr>
  75. <td><code>image is-5by4</code></td>
  76. <td><figure class="image is-5by4"><img src="{{site.url}}/images/placeholders/600x480.png"></figure></td>
  77. <td>5 by 4</td>
  78. </tr>
  79. <tr>
  80. <td><code>image is-4by3</code></td>
  81. <td><figure class="image is-4by3"><img src="{{site.url}}/images/placeholders/640x480.png"></figure></td>
  82. <td>4 by 3</td>
  83. </tr>
  84. <tr>
  85. <td><code>image is-3by2</code></td>
  86. <td><figure class="image is-3by2"><img src="{{site.url}}/images/placeholders/480x320.png"></figure></td>
  87. <td>3 by 2</td>
  88. </tr>
  89. <tr>
  90. <td><code>image is-5by3</code></td>
  91. <td><figure class="image is-5by3"><img src="{{site.url}}/images/placeholders/800x480.png"></figure></td>
  92. <td>5 by 3</td>
  93. </tr>
  94. <tr>
  95. <td><code>image is-16by9</code></td>
  96. <td><figure class="image is-16by9"><img src="{{site.url}}/images/placeholders/640x360.png"></figure></td>
  97. <td>16 by 9</td>
  98. </tr>
  99. <tr>
  100. <td><code>image is-2by1</code></td>
  101. <td><figure class="image is-2by1"><img src="{{site.url}}/images/placeholders/640x320.png"></figure></td>
  102. <td>2 by 1</td>
  103. </tr>
  104. <tr>
  105. <td><code>image is-3by1</code></td>
  106. <td><figure class="image is-3by1"><img src="{{site.url}}/images/placeholders/720x240.png"></figure></td>
  107. <td>3 by 1</td>
  108. </tr>
  109. <tr>
  110. <td><code>image is-4by5</code></td>
  111. <td><figure class="image is-4by5"><img src="{{site.url}}/images/placeholders/480x600.png"></figure></td>
  112. <td>4 by 5</td>
  113. </tr>
  114. <tr>
  115. <td><code>image is-3by4</code></td>
  116. <td><figure class="image is-3by4"><img src="{{site.url}}/images/placeholders/480x640.png"></figure></td>
  117. <td>3 by 4</td>
  118. </tr>
  119. <tr>
  120. <td><code>image is-2by3</code></td>
  121. <td><figure class="image is-2by3"><img src="{{site.url}}/images/placeholders/320x480.png"></figure></td>
  122. <td>2 by 3</td>
  123. </tr>
  124. <tr>
  125. <td><code>image is-3by5</code></td>
  126. <td><figure class="image is-3by5"><img src="{{site.url}}/images/placeholders/480x800.png"></figure></td>
  127. <td>3 by 5</td>
  128. </tr>
  129. <tr>
  130. <td><code>image is-9by16</code></td>
  131. <td><figure class="image is-9by16"><img src="{{site.url}}/images/placeholders/360x640.png"></figure></td>
  132. <td>9 by 16</td>
  133. </tr>
  134. <tr>
  135. <td><code>image is-1by2</code></td>
  136. <td><figure class="image is-1by2"><img src="{{site.url}}/images/placeholders/320x640.png"></figure></td>
  137. <td>1 by 2</td>
  138. </tr>
  139. <tr>
  140. <td><code>image is-1by3</code></td>
  141. <td><figure class="image is-1by3"><img src="{{site.url}}/images/placeholders/240x720.png"></figure></td>
  142. <td>1 by 3</td>
  143. </tr>
  144. </tbody>
  145. </table>
  146. <div class="content">
  147. <p>The <code>.image</code> container will take up the <strong>whole width</strong> while maintaining the perfect ratio.</p>
  148. </div>
  149. {% include elements/variables.html type='element' %}