2016-09-11 11:00:49 +00:00
|
|
|
---
|
2017-07-29 12:02:00 +00:00
|
|
|
title: Container
|
2024-03-21 16:11:54 +00:00
|
|
|
layout: docs
|
|
|
|
theme: library
|
2021-01-27 23:30:42 +00:00
|
|
|
fullwidth: true
|
2018-04-10 10:45:48 +00:00
|
|
|
hide_categories: true
|
2016-09-11 11:00:49 +00:00
|
|
|
doc-tab: layout
|
|
|
|
doc-subtab: container
|
2018-04-09 15:50:33 +00:00
|
|
|
breadcrumb:
|
2024-03-21 16:11:54 +00:00
|
|
|
- home
|
|
|
|
- documentation
|
|
|
|
- layout
|
|
|
|
- layout-container
|
2020-09-27 22:50:12 +00:00
|
|
|
meta:
|
|
|
|
colors: false
|
|
|
|
sizes: true
|
|
|
|
variables: true
|
2016-09-11 11:00:49 +00:00
|
|
|
---
|
2024-07-07 16:59:24 +00:00
|
|
|
|
2017-07-21 09:22:08 +00:00
|
|
|
{% capture container_example %}
|
|
|
|
<div class="container">
|
2020-09-27 22:50:12 +00:00
|
|
|
<div class="notification is-primary">
|
|
|
|
This container is <strong>centered</strong> on desktop and larger viewports.
|
2017-07-21 09:22:08 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-07-07 16:59:24 +00:00
|
|
|
{% endcapture %} {% capture container_fluid_example %}
|
2017-07-21 09:22:08 +00:00
|
|
|
<div class="container is-fluid">
|
2020-09-27 22:50:12 +00:00
|
|
|
<div class="notification is-primary">
|
2024-03-21 16:11:54 +00:00
|
|
|
This container is <strong>fluid</strong>: it will have a 32px gap on either
|
|
|
|
side, on any viewport size.
|
2017-07-21 09:22:08 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-07-07 16:59:24 +00:00
|
|
|
{% endcapture %} {% capture container_widescreen_example %}
|
2017-07-21 09:22:08 +00:00
|
|
|
<div class="container is-widescreen">
|
2020-09-27 22:50:12 +00:00
|
|
|
<div class="notification is-primary">
|
2024-03-21 16:11:54 +00:00
|
|
|
This container is <strong>fullwidth</strong> <em>until</em> the
|
|
|
|
<code>$widescreen</code> breakpoint.
|
2017-07-21 09:22:08 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-07-07 16:59:24 +00:00
|
|
|
{% endcapture %} {% capture container_fullhd_example %}
|
2017-07-21 09:22:08 +00:00
|
|
|
<div class="container is-fullhd">
|
2020-09-27 22:50:12 +00:00
|
|
|
<div class="notification is-primary">
|
2024-03-21 16:11:54 +00:00
|
|
|
This container is <strong>fullwidth</strong> <em>until</em> the
|
|
|
|
<code>$fullhd</code> breakpoint.
|
2017-07-21 09:22:08 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-07-07 16:59:24 +00:00
|
|
|
{% endcapture %} {% capture container_max_tablet_example %}
|
|
|
|
<div class="container is-max-tablet">
|
|
|
|
<div class="notification is-primary">
|
|
|
|
This container has a <code>max-width</code> of
|
|
|
|
<code>$tablet - $container-offset</code>.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% endcapture %} {% capture container_max_desktop_example %}
|
2020-09-27 22:50:12 +00:00
|
|
|
<div class="container is-max-desktop">
|
|
|
|
<div class="notification is-primary">
|
2024-03-21 16:11:54 +00:00
|
|
|
This container has a <code>max-width</code> of
|
|
|
|
<code>$desktop - $container-offset</code> on widescreen and fullhd.
|
2020-09-27 22:50:12 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-07-07 16:59:24 +00:00
|
|
|
{% endcapture %} {% capture container_max_widescreen_example %}
|
2020-09-27 22:50:12 +00:00
|
|
|
<div class="container is-max-widescreen">
|
|
|
|
<div class="notification is-primary">
|
2024-03-21 16:11:54 +00:00
|
|
|
This container has a <code>max-width</code> of
|
|
|
|
<code>$widescreen - $container-offset</code> on fullhd.
|
2020-09-27 22:50:12 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-07-07 16:59:24 +00:00
|
|
|
{% endcapture %} {% assign bp_tablet = site.data.breakpoints.tablet %} {% assign
|
|
|
|
bp_desktop = site.data.breakpoints.desktop %} {% assign bp_widescreen =
|
|
|
|
site.data.breakpoints.widescreen %} {% assign bp_fullhd =
|
|
|
|
site.data.breakpoints.fullhd %} {% assign container_offset = 64 %} {% capture
|
|
|
|
thead %}
|
2020-09-27 22:50:12 +00:00
|
|
|
<thead>
|
|
|
|
<tr>
|
2024-03-21 16:11:54 +00:00
|
|
|
<th class="bd-is-empty"></th>
|
|
|
|
{% for breakpoint_hash in site.data.breakpoints %} {% assign breakpoint =
|
|
|
|
breakpoint_hash[1] %} {% if breakpoint.id == 'tablet' %}
|
|
|
|
<th>
|
|
|
|
Below
|
|
|
|
<br />
|
|
|
|
<code>{{ bp_tablet.to }}px</code>
|
2020-09-27 22:50:12 +00:00
|
|
|
</th>
|
2024-03-21 16:11:54 +00:00
|
|
|
{% elsif breakpoint.id != 'mobile' %}
|
|
|
|
<th>
|
|
|
|
{{ breakpoint.name }}
|
|
|
|
<br />
|
|
|
|
{% if breakpoint.id == 'fullhd' %}
|
|
|
|
<code>{{ breakpoint.from }}px</code> and above {% else %} Between
|
|
|
|
<code>{{ breakpoint.from }}px</code> and
|
|
|
|
<code>{{ breakpoint.to }}px</code>
|
2020-09-27 22:50:12 +00:00
|
|
|
{% endif %}
|
2024-03-21 16:11:54 +00:00
|
|
|
</th>
|
|
|
|
{% endif %} {% endfor %}
|
2020-09-27 22:50:12 +00:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
{% endcapture %}
|
|
|
|
|
2018-04-09 15:15:58 +00:00
|
|
|
<div class="content">
|
2020-09-27 22:50:12 +00:00
|
|
|
<p>
|
2024-07-07 16:59:24 +00:00
|
|
|
The <code>container</code> is a simple utility element that allows you to
|
|
|
|
<strong>center</strong> content on larger viewports. It can be used in any
|
|
|
|
context, but mostly as a <strong>direct child</strong> of one of the
|
|
|
|
following:
|
2020-09-27 22:50:12 +00:00
|
|
|
</p>
|
2018-04-09 15:15:58 +00:00
|
|
|
<ul>
|
2019-10-13 21:58:12 +00:00
|
|
|
<li><code>navbar</code></li>
|
|
|
|
<li><code>hero</code></li>
|
|
|
|
<li><code>section</code></li>
|
|
|
|
<li><code>footer</code></li>
|
2018-04-09 15:15:58 +00:00
|
|
|
</ul>
|
2020-09-27 22:50:12 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- -->
|
2024-03-21 16:11:54 +00:00
|
|
|
{% include docs/elements/anchor.html name="Overview" %}
|
2020-09-27 22:50:12 +00:00
|
|
|
|
|
|
|
<div class="table-container">
|
|
|
|
<table class="table is-bordered">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
{{ thead }}
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>Class</th>
|
|
|
|
<th colspan="4" class="has-text-centered"><code>max-width</code></th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td><code>.container</code></td>
|
|
|
|
<td class="has-text-grey-light has-background-white-ter">Full width</td>
|
2024-03-21 16:11:54 +00:00
|
|
|
<td>
|
|
|
|
<code>{{ bp_desktop.from | minus: container_offset }}px</code>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<code>{{ bp_widescreen.from | minus: container_offset }}px</code>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<code>{{ bp_fullhd.from | minus: container_offset }}px</code>
|
|
|
|
</td>
|
2020-09-27 22:50:12 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>.container.is-widescreen</code></td>
|
2024-07-07 16:59:24 +00:00
|
|
|
<td colspan="2" class="has-text-grey-light has-background-white-ter">
|
|
|
|
Full width
|
|
|
|
</td>
|
2024-03-21 16:11:54 +00:00
|
|
|
<td>
|
|
|
|
<code>{{ bp_widescreen.from | minus: container_offset }}px</code>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<code>{{ bp_fullhd.from | minus: container_offset }}px</code>
|
|
|
|
</td>
|
2020-09-27 22:50:12 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>.container.is-fullhd</code></td>
|
2024-07-07 16:59:24 +00:00
|
|
|
<td colspan="3" class="has-text-grey-light has-background-white-ter">
|
|
|
|
Full width
|
|
|
|
</td>
|
2024-03-21 16:11:54 +00:00
|
|
|
<td>
|
|
|
|
<code>{{ bp_fullhd.from | minus: container_offset }}px</code>
|
2020-09-27 22:50:12 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>.container.is-max-desktop</code></td>
|
|
|
|
<td class="has-text-grey-light has-background-white-ter">Full width</td>
|
2024-03-21 16:11:54 +00:00
|
|
|
<td colspan="3">
|
|
|
|
<code>{{ bp_desktop.from | minus: container_offset }}px</code>
|
|
|
|
</td>
|
2020-09-27 22:50:12 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>.container.is-max-widescreen</code></td>
|
|
|
|
<td class="has-text-grey-light has-background-white-ter">Full width</td>
|
2024-03-21 16:11:54 +00:00
|
|
|
<td>
|
|
|
|
<code>{{ bp_desktop.from | minus: container_offset }}px</code>
|
|
|
|
</td>
|
|
|
|
<td colspan="2">
|
|
|
|
<code>{{ bp_widescreen.from | minus: container_offset }}px</code>
|
|
|
|
</td>
|
2020-09-27 22:50:12 +00:00
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- -->
|
2024-03-21 16:11:54 +00:00
|
|
|
{% include docs/elements/anchor.html name="Default behavior" %}
|
2020-09-27 22:50:12 +00:00
|
|
|
|
|
|
|
<div class="content">
|
|
|
|
<p>
|
2024-07-07 16:59:24 +00:00
|
|
|
By default, the <code>container</code> will only be activated from the
|
|
|
|
<code>$desktop</code> breakpoint. It will increase its
|
|
|
|
<code>max-width</code> after reaching the <code>$widescreen</code> and
|
2024-03-21 16:11:54 +00:00
|
|
|
<code>$fullhd</code> breakpoints.
|
2020-09-27 22:50:12 +00:00
|
|
|
</p>
|
2018-04-09 15:15:58 +00:00
|
|
|
<p>
|
2024-07-07 16:59:24 +00:00
|
|
|
The container's <strong>width</strong> for each
|
|
|
|
<strong>breakpoint</strong> is the result of:
|
|
|
|
<code>$device - (2 * $gap)</code>. The <code>$gap</code> variable has a
|
|
|
|
default value of <code> 32px</code> but can be modified.
|
2018-04-09 15:15:58 +00:00
|
|
|
</p>
|
|
|
|
<p>This is how the container will behave:</p>
|
|
|
|
<ul>
|
2024-07-07 16:59:24 +00:00
|
|
|
<li>
|
|
|
|
on <code>$desktop</code> it will have a maximum width of
|
|
|
|
<strong>960px</strong>.
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
on <code>$widescreen</code> it will have a maximum width of
|
|
|
|
<strong>1152px</strong>.
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
on <code>$fullhd</code> it will have a maximum width of
|
|
|
|
<strong>1344px</strong>.
|
|
|
|
</li>
|
2018-04-09 15:15:58 +00:00
|
|
|
</ul>
|
2024-03-21 16:11:54 +00:00
|
|
|
<p>
|
2024-07-07 16:59:24 +00:00
|
|
|
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>.
|
2024-03-21 16:11:54 +00:00
|
|
|
</p>
|
2018-04-09 15:15:58 +00:00
|
|
|
</div>
|
|
|
|
|
2024-03-21 16:11:54 +00:00
|
|
|
<div class="bd-example is-fullwidth">{{ container_example }}</div>
|
2017-07-21 09:22:08 +00:00
|
|
|
|
2024-07-07 16:59:24 +00:00
|
|
|
{% highlight html -%} {{- container_example -}} {%- endhighlight %}
|
2018-04-09 15:15:58 +00:00
|
|
|
|
2020-09-27 22:50:12 +00:00
|
|
|
<!-- -->
|
2024-03-21 16:11:54 +00:00
|
|
|
{% include docs/elements/anchor.html name="Widescreen or FullHD only" %}
|
2019-10-13 21:58:12 +00:00
|
|
|
|
2018-04-09 15:15:58 +00:00
|
|
|
<div class="content">
|
2020-09-27 22:50:12 +00:00
|
|
|
<p>
|
2024-07-07 16:59:24 +00:00
|
|
|
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.
|
2020-09-27 22:50:12 +00:00
|
|
|
</p>
|
2016-09-11 11:00:49 +00:00
|
|
|
</div>
|
2018-04-09 15:15:58 +00:00
|
|
|
|
2024-03-21 16:11:54 +00:00
|
|
|
<div class="bd-example is-fullwidth">{{ container_widescreen_example }}</div>
|
2016-09-11 11:00:49 +00:00
|
|
|
|
2024-07-07 16:59:24 +00:00
|
|
|
{% highlight html -%} {{- container_widescreen_example -}} {%- endhighlight %}
|
2020-09-27 22:50:12 +00:00
|
|
|
|
2024-03-21 16:11:54 +00:00
|
|
|
<div class="bd-example is-fullwidth">{{ container_fullhd_example }}</div>
|
2018-04-09 15:15:58 +00:00
|
|
|
|
2024-07-07 16:59:24 +00:00
|
|
|
{% highlight html -%} {{- container_fullhd_example -}} {%- endhighlight %}
|
2020-09-27 22:50:12 +00:00
|
|
|
|
|
|
|
<!-- -->
|
2024-07-07 16:59:24 +00:00
|
|
|
{% include docs/elements/anchor.html name="Tablet, Desktop and Widescreen
|
|
|
|
maximum widths" %}
|
2019-10-13 21:58:12 +00:00
|
|
|
|
2018-04-09 15:15:58 +00:00
|
|
|
<div class="content">
|
|
|
|
<p>
|
2024-07-07 16:59:24 +00:00
|
|
|
Sometimes, you might want a <strong>narrow</strong> container on larger
|
|
|
|
viewports. That's why Bulma provides 3 modifier classes:
|
2018-04-09 15:15:58 +00:00
|
|
|
</p>
|
2020-09-27 22:50:12 +00:00
|
|
|
<ul>
|
2024-07-07 16:59:24 +00:00
|
|
|
<li>
|
|
|
|
<code>.container.is-max-tablet</code> will behave like a tablet container
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<code>.container.is-max-desktop</code> will behave like a desktop
|
|
|
|
container
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<code>.container.is-max-widescreen</code> will behave like a widescreen
|
|
|
|
container
|
|
|
|
</li>
|
2020-09-27 22:50:12 +00:00
|
|
|
</ul>
|
2016-09-11 11:00:49 +00:00
|
|
|
</div>
|
2018-04-09 15:15:58 +00:00
|
|
|
|
2024-07-07 16:59:24 +00:00
|
|
|
<div class="bd-example is-fullwidth">{{ container_max_tablet_example }}</div>
|
|
|
|
|
|
|
|
{% highlight html -%} {{- container_max_tablet_example -}} {%- endhighlight %}
|
|
|
|
|
2024-03-21 16:11:54 +00:00
|
|
|
<div class="bd-example is-fullwidth">{{ container_max_desktop_example }}</div>
|
2017-07-21 09:22:08 +00:00
|
|
|
|
2024-07-07 16:59:24 +00:00
|
|
|
{% highlight html -%} {{- container_max_desktop_example -}} {%- endhighlight %}
|
2018-04-09 15:15:58 +00:00
|
|
|
|
2021-01-27 23:30:42 +00:00
|
|
|
<div class="bd-example is-fullwidth">
|
2020-09-27 22:50:12 +00:00
|
|
|
{{ container_max_widescreen_example }}
|
2017-07-21 09:22:08 +00:00
|
|
|
</div>
|
|
|
|
|
2024-07-07 16:59:24 +00:00
|
|
|
{% highlight html -%} {{- container_max_widescreen_example -}} {%- endhighlight
|
|
|
|
%}
|
2020-09-27 22:50:12 +00:00
|
|
|
|
|
|
|
<!-- -->
|
2024-03-21 16:11:54 +00:00
|
|
|
{% include docs/elements/anchor.html name="Absolute maximum width" %}
|
2020-09-27 22:50:12 +00:00
|
|
|
|
|
|
|
<div class="content">
|
|
|
|
<p>
|
2024-07-07 16:59:24 +00:00
|
|
|
If you want to change the maximum width of <strong>all</strong> containers,
|
|
|
|
you can do so by updating the values of the
|
|
|
|
<code>$container-max-width</code> Sass variable.
|
2020-09-27 22:50:12 +00:00
|
|
|
</p>
|
|
|
|
<p>
|
2024-07-07 16:59:24 +00:00
|
|
|
By default, the <code>$fullhd</code> breakpoint value is used to calculate
|
|
|
|
the <strong>absolute</strong> maximum width of the <code>container</code>.
|
|
|
|
Simply change it to a smaller value like <code>$widescreen</code>,
|
2024-03-21 16:11:54 +00:00
|
|
|
<code>$desktop</code>, or any value in <strong>pixels</strong>.
|
2020-09-27 22:50:12 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- -->
|
2024-03-21 16:11:54 +00:00
|
|
|
{% include docs/elements/anchor.html name="Fluid container" %}
|
2020-09-27 22:50:12 +00:00
|
|
|
|
|
|
|
<div class="content">
|
2024-03-21 16:11:54 +00:00
|
|
|
<p>
|
2024-07-07 16:59:24 +00:00
|
|
|
If you don't want to have a maximum width but want to keep the 32px margin
|
|
|
|
on the left and right sides, add the
|
2024-03-21 16:11:54 +00:00
|
|
|
<code>is-fluid</code> modifier:
|
|
|
|
</p>
|
2020-09-27 22:50:12 +00:00
|
|
|
</div>
|
|
|
|
|
2024-03-21 16:11:54 +00:00
|
|
|
<div class="bd-example is-fullwidth">{{ container_fluid_example }}</div>
|
2020-09-27 22:50:12 +00:00
|
|
|
|
2024-07-07 16:59:24 +00:00
|
|
|
{% highlight html -%} {{- container_fluid_example -}} {%- endhighlight %} {%
|
|
|
|
include docs/components/variables.html type='element'
|
|
|
|
data=site.data.variables.elements.container %}
|