container.html 3.5 KB

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