image.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. variables:
  15. - name: $dimensions
  16. value: 16 24 32 48 64 96 128
  17. ---
  18. {% capture image %}
  19. <figure class="image is-128x128">
  20. <img src="{{site.url}}/images/placeholders/128x128.png">
  21. </figure>
  22. {% endcapture %}
  23. {% capture retina_image %}
  24. <figure class="image is-128x128">
  25. <img src="{{site.url}}/images/placeholders/256x256.png">
  26. </figure>
  27. {% endcapture %}
  28. {% include subnav-elements.html %}
  29. <section class="section">
  30. <div class="container">
  31. <h1 class="title">Images</h1>
  32. <h2 class="subtitle">
  33. A container for <strong>responsive images</strong>
  34. </h2>
  35. {%
  36. include meta.html
  37. colors=false
  38. sizes=false
  39. variables=true
  40. %}
  41. <hr>
  42. <div class="content">
  43. <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>
  44. </div>
  45. {% include snippet.html content=image %}
  46. {% include anchor.html name="Fixed square images" %}
  47. <div class="content">
  48. <p>There are <strong>7</strong> dimensions to choose from, useful for <strong>avatars</strong>:</p>
  49. </div>
  50. <table class="table is-bordered">
  51. <tbody>
  52. {% for dimension in page.dimensions %}
  53. <tr>
  54. <td><code>image is-{{ dimension }}x{{ dimension }}</code></td>
  55. <td><figure class="image is-{{ dimension }}x{{ dimension }}"><img src="{{site.url}}/images/placeholders/{{ dimension }}x{{ dimension }}.png"></figure></td>
  56. <td>{{ dimension }}x{{ dimension }}px</td>
  57. </tr>
  58. {% endfor %}
  59. </tbody>
  60. </table>
  61. {% include anchor.html name="Retina images" %}
  62. <div class="content">
  63. <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>
  64. </div>
  65. {% include snippet.html content=retina_image %}
  66. {% include anchor.html name="Responsive images with ratios" %}
  67. <div class="content">
  68. <p>If you don't know the exact dimensions but know the <strong>ratio</strong> instead, you can use one of the <strong>5 ratio modifers</strong>:</p>
  69. </div>
  70. <table id="images" class="table is-bordered">
  71. <tbody>
  72. <tr>
  73. <td><code>image is-square</code></td>
  74. <td><figure class="image is-square"><img src="{{site.url}}/images/placeholders/480x480.png"></figure></td>
  75. <td>Square (or 1by1)</td>
  76. </tr>
  77. <tr>
  78. <td><code>image is-1by1</code></td>
  79. <td><figure class="image is-1by1"><img src="{{site.url}}/images/placeholders/480x480.png"></figure></td>
  80. <td>1 by 1</td>
  81. </tr>
  82. <tr>
  83. <td><code>image is-4by3</code></td>
  84. <td><figure class="image is-4by3"><img src="{{site.url}}/images/placeholders/640x480.png"></figure></td>
  85. <td>4 by 3</td>
  86. </tr>
  87. <tr>
  88. <td><code>image is-3by2</code></td>
  89. <td><figure class="image is-3by2"><img src="{{site.url}}/images/placeholders/480x320.png"></figure></td>
  90. <td>3 by 2</td>
  91. </tr>
  92. <tr>
  93. <td><code>image is-16by9</code></td>
  94. <td><figure class="image is-16by9"><img src="{{site.url}}/images/placeholders/640x360.png"></figure></td>
  95. <td>16 by 9</td>
  96. </tr>
  97. <tr>
  98. <td><code>image is-2by1</code></td>
  99. <td><figure class="image is-2by1"><img src="{{site.url}}/images/placeholders/640x320.png"></figure></td>
  100. <td>2 by 1</td>
  101. </tr>
  102. </tbody>
  103. </table>
  104. <div class="content">
  105. <p>The <code>.image</code> container will take up the <strong>whole width</strong> while maintaining the perfect ratio.</p>
  106. </div>
  107. {% include variables.html %}
  108. </div>
  109. </section>