container.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. ---
  2. title: Container
  3. subtitle: "A simple <strong>container</strong> to center your content horizontally"
  4. layout: documentation
  5. hide_carbon: true
  6. doc-tab: layout
  7. doc-subtab: container
  8. breadcrumb:
  9. - home
  10. - documentation
  11. - layout
  12. - layout-container
  13. ---
  14. {% capture container_example %}
  15. <div class="container">
  16. <div class="notification">
  17. This container is <strong>centered</strong> on desktop.
  18. </div>
  19. </div>
  20. {% endcapture %}
  21. {% capture container_fluid_example %}
  22. <div class="container is-fluid">
  23. <div class="notification">
  24. This container is <strong>fluid</strong>: it will have a 32px gap on either side, on any
  25. viewport size.
  26. </div>
  27. </div>
  28. {% endcapture %}
  29. {% capture container_widescreen_example %}
  30. <div class="container is-widescreen">
  31. <div class="notification">
  32. This container is <strong>fullwidth</strong> <em>until</em> the <code>$widescreen</code> breakpoint.
  33. </div>
  34. </div>
  35. {% endcapture %}
  36. {% capture container_fullhd_example %}
  37. <div class="container is-fullhd">
  38. <div class="notification">
  39. This container is <strong>fullwidth</strong> <em>until</em> the <code>$fullhd</code> breakpoint.
  40. </div>
  41. </div>
  42. {% endcapture %}
  43. <div class="content">
  44. <p>The <code>.container</code> class can be used in any context, but mostly as a <strong>direct child</strong> of either:</p>
  45. <ul>
  46. <li><code>.navbar</code></li>
  47. <li><code>.hero</code></li>
  48. <li><code>.section</code></li>
  49. <li><code>.footer</code></li>
  50. </ul>
  51. <p>
  52. The containers <strong>width</strong> for each <strong>breakpoint</strong> is the result
  53. of: <code>$device - (2 * $gap)</code>. The <code>$gap</code> variable has a default value of <code>
  54. 32px</code> but can be modified.
  55. </p>
  56. <p>This is how the container will behave:</p>
  57. <ul>
  58. <li>on <code>$desktop</code> it will have a maximum width of <strong>960px</strong>.</li>
  59. <li>on <code>$widescreen</code> it will have a maximum width of <strong>1152px</strong>.</li>
  60. <li>on <code>$fullhd</code> it will have a maximum width of <strong>1344px</strong>.</li>
  61. </ul>
  62. <p>The values <strong>960</strong>, <strong>1152</strong> and <strong>1344</strong> have been chosen because they are divisible by both <strong>12</strong> and <strong>16</strong>.</p>
  63. </div>
  64. {% include layout/main-close.html %}
  65. <div class="bd-example is-fullwidth">
  66. {{container_example}}
  67. </div>
  68. {% include layout/main-open.html %}
  69. {% highlight html %}{{ container_example }}{% endhighlight %}
  70. <h3 class="title is-4">Fluid container</h3>
  71. <div class="content">
  72. <p>If you don't want to have a maximum width but want to keep the 32px margin on the left and
  73. right sides, add the <code>is-fluid</code> modifier:</p>
  74. </div>
  75. {% include layout/main-close.html %}
  76. <div class="bd-example is-fullwidth">
  77. {{container_fluid_example}}
  78. </div>
  79. {% include layout/main-open.html %}
  80. {% highlight html %}{{ container_fluid_example }}{% endhighlight %}
  81. <h3 class="title is-4">Breakpoint containers</h3>
  82. <div class="content">
  83. <p>
  84. With the two modifiers <code>.is-widescreen</code> and <code>.is-fullhd</code>, you can have a <em>fullwidth</em> container <strong>until</strong> those specific breakpoints.
  85. </p>
  86. </div>
  87. {% include layout/main-close.html %}
  88. <div class="bd-example is-fullwidth">
  89. {{container_widescreen_example}}
  90. </div>
  91. {% include layout/main-open.html %}
  92. {% highlight html %}{{ container_widescreen_example }}{% endhighlight %}
  93. {% include layout/main-close.html %}
  94. <div class="bd-example is-fullwidth">
  95. {{ container_fullhd_example }}
  96. </div>
  97. {% include layout/main-open.html %}
  98. {% highlight html %}{{ container_fullhd_example }}{% endhighlight %}