2020-05-10 21:10:51 +00:00
|
|
|
---
|
|
|
|
title: Spacing helpers
|
2024-03-21 16:11:54 +00:00
|
|
|
layout: docs
|
|
|
|
theme: helpers
|
2020-05-10 21:10:51 +00:00
|
|
|
doc-tab: helpers
|
|
|
|
doc-subtab: helpers-spacing
|
|
|
|
breadcrumb:
|
2024-03-21 16:11:54 +00:00
|
|
|
- home
|
|
|
|
- documentation
|
|
|
|
- helpers
|
|
|
|
- helpers-spacing
|
2020-05-10 23:25:29 +00:00
|
|
|
shortcuts:
|
|
|
|
margin: m
|
|
|
|
padding: p
|
|
|
|
directions:
|
2020-08-27 09:46:39 +00:00
|
|
|
all: a
|
2020-05-10 23:25:29 +00:00
|
|
|
top: t
|
|
|
|
right: r
|
|
|
|
bottom: b
|
|
|
|
left: l
|
|
|
|
horizontal: x
|
|
|
|
vertical: y
|
|
|
|
values:
|
|
|
|
0: 0
|
|
|
|
1: 0.25rem
|
|
|
|
2: 0.5rem
|
|
|
|
3: 0.75rem
|
|
|
|
4: 1rem
|
|
|
|
5: 1.5rem
|
|
|
|
6: 3rem
|
2021-06-18 17:27:34 +00:00
|
|
|
auto: auto
|
2020-05-11 00:03:16 +00:00
|
|
|
customShortcuts:
|
|
|
|
margin: mg
|
|
|
|
customHorizontal: h
|
|
|
|
customValues:
|
|
|
|
small: 10px
|
|
|
|
medium: 30px
|
|
|
|
large: 60px
|
2020-05-10 21:10:51 +00:00
|
|
|
---
|
|
|
|
|
2020-05-10 23:25:29 +00:00
|
|
|
<div class="content">
|
2024-03-21 16:11:54 +00:00
|
|
|
<p>
|
|
|
|
Bulma provides <strong>margin</strong> <code>m*</code> and
|
|
|
|
<strong>padding</strong> <code>p*</code> helpers in all
|
|
|
|
<strong>directions</strong>:
|
|
|
|
</p>
|
2020-05-10 23:25:29 +00:00
|
|
|
|
|
|
|
<ul>
|
2024-03-21 16:11:54 +00:00
|
|
|
<li><code>*t</code> for <strong>top</strong></li>
|
|
|
|
<li><code>*r</code> for <strong>right</strong></li>
|
|
|
|
<li><code>*b</code> for <strong>bottom</strong></li>
|
|
|
|
<li><code>*l</code> for <strong>left</strong></li>
|
2020-05-10 23:25:29 +00:00
|
|
|
<li>
|
2024-03-21 16:11:54 +00:00
|
|
|
<code>*x</code> horizontally for both <strong>left</strong> and
|
|
|
|
<strong>right</strong>
|
2020-05-10 23:25:29 +00:00
|
|
|
</li>
|
|
|
|
<li>
|
2024-03-21 16:11:54 +00:00
|
|
|
<code>*y</code> vertically for both <strong>top</strong> and
|
|
|
|
<strong>bottom</strong>
|
2020-05-10 23:25:29 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<p>
|
2024-03-21 16:11:54 +00:00
|
|
|
You need to <strong>combine</strong> a margin/padding prefix with a
|
|
|
|
direction suffix. For example:
|
2020-05-10 23:25:29 +00:00
|
|
|
</p>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
<li>for a <code>margin-top</code>, use <code>mt-*</code></li>
|
|
|
|
<li>for a <code>padding-bottom</code>, use <code>pb-*</code></li>
|
2024-03-21 16:11:54 +00:00
|
|
|
<li>
|
|
|
|
for both <code>margin-left</code> and <code>margin-right</code>, use
|
|
|
|
<code>mx-*</code>
|
|
|
|
</li>
|
2020-05-10 23:25:29 +00:00
|
|
|
</ul>
|
|
|
|
|
|
|
|
<p>
|
2024-03-21 16:11:54 +00:00
|
|
|
Each of these <code>property-direction</code>
|
|
|
|
<strong>combinations</strong> needs to be appended with one of
|
|
|
|
<strong>6 value suffixes</strong>:
|
2020-05-10 23:25:29 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<table class="table is-bordered">
|
|
|
|
<thead>
|
|
|
|
<th>Suffix</th>
|
|
|
|
<th>Value</th>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2024-03-21 16:11:54 +00:00
|
|
|
<tr>
|
|
|
|
<td><code>*-0</code></td>
|
|
|
|
<td><code>0</code></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>*-1</code></td>
|
|
|
|
<td><code>0.25rem</code></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>*-2</code></td>
|
|
|
|
<td><code>0.5rem</code></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>*-3</code></td>
|
|
|
|
<td><code>0.75rem</code></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>*-4</code></td>
|
|
|
|
<td><code>1rem</code></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>*-5</code></td>
|
|
|
|
<td><code>1.5rem</code></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>*-6</code></td>
|
|
|
|
<td><code>3rem</code></td>
|
|
|
|
</tr>
|
2020-05-10 23:25:29 +00:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
2024-03-21 16:11:54 +00:00
|
|
|
{% include docs/elements/anchor.html name="List of all spacing helpers" %}
|
2020-05-10 23:25:29 +00:00
|
|
|
|
2020-05-13 12:09:44 +00:00
|
|
|
<p class="block">
|
2021-06-18 17:27:34 +00:00
|
|
|
There are <strong>112 spacing helpers</strong> to choose from:
|
2020-05-11 00:03:16 +00:00
|
|
|
</p>
|
|
|
|
|
2024-03-21 16:11:54 +00:00
|
|
|
{% include docs/components/spacing-table.html values=page.values
|
|
|
|
shortcuts=page.shortcuts directions=page.directions horizontal=page.horizontal
|
|
|
|
vertical=page.vertical %}
|
2020-05-11 00:03:16 +00:00
|
|
|
|
2020-06-07 12:23:16 +00:00
|
|
|
<div class="content">
|
2024-03-21 16:11:54 +00:00
|
|
|
<p>To use these classes, simply append them to any HTML element:</p>
|
2020-06-07 12:23:16 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
{% highlight html %}
|
|
|
|
<!-- Adds 1rem of margin at the bottom -->
|
2024-03-21 16:11:54 +00:00
|
|
|
<p class="mb-4">Margin bottom</p>
|
2020-06-07 12:23:16 +00:00
|
|
|
|
|
|
|
<!-- Adds 0.25rem of padding on the left and the right -->
|
2024-03-21 16:11:54 +00:00
|
|
|
<p class="px-1">Horizontal padding</p>
|
2020-06-07 12:23:16 +00:00
|
|
|
|
|
|
|
<!-- Removes the margin on the right and adds 0.75rem padding at the top -->
|
2024-03-21 16:11:54 +00:00
|
|
|
<p class="mr-0 pt-3">Both</p>
|
|
|
|
{% endhighlight %} {% include docs/elements/anchor.html name="Configuration" %}
|
|
|
|
{% capture custom %} $spacing-shortcuts: ("margin": "mg"); $spacing-horizontal:
|
|
|
|
"h"; $spacing-vertical: null; $spacing-values: ("small": 10px, "medium": 30px,
|
|
|
|
"large": 60px); {% endcapture %}
|
2020-05-11 00:03:16 +00:00
|
|
|
|
|
|
|
<div class="content">
|
|
|
|
<p>
|
2024-03-21 16:11:54 +00:00
|
|
|
Because every developer has their own preferences, and to satisfy Bulma's
|
|
|
|
customization features, it's possible to specify your own
|
|
|
|
<strong>class name shortcuts</strong> as well as the
|
|
|
|
<strong>spacing values</strong>.
|
2020-05-11 00:03:16 +00:00
|
|
|
</p>
|
2024-03-21 16:11:54 +00:00
|
|
|
<p>For example, if you wanted:</p>
|
2020-05-11 00:03:16 +00:00
|
|
|
<ul>
|
2024-03-21 16:11:54 +00:00
|
|
|
<li><strong>margin</strong> to be abbreviated to <code>mg</code></li>
|
2020-05-11 00:03:16 +00:00
|
|
|
<li>
|
2024-03-21 16:11:54 +00:00
|
|
|
<strong>padding</strong> to be totally
|
|
|
|
<strong class="has-text-danger">excluded</strong>
|
2020-05-11 00:03:16 +00:00
|
|
|
</li>
|
2024-03-21 16:11:54 +00:00
|
|
|
<li><strong>horizontal</strong> to be abbreviated to <code>h</code></li>
|
|
|
|
<li><strong>vertical</strong> to be excluded as well</li>
|
2020-05-11 00:03:16 +00:00
|
|
|
<li>
|
2024-03-21 16:11:54 +00:00
|
|
|
and to only have 3 values: <strong>"small"</strong> at <code>10px</code>,
|
|
|
|
<strong>"medium"</strong> at <code>30px</code>, and
|
|
|
|
<strong>"large"</strong> at <code>60px</code>
|
2020-05-11 00:03:16 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p>
|
2024-03-21 16:11:54 +00:00
|
|
|
You can simplify the CSS output by customizing these
|
|
|
|
<strong>SCSS variables</strong>:
|
2020-05-11 00:03:16 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
2024-03-21 16:11:54 +00:00
|
|
|
{% highlight scss -%} {{- custom -}} {%- endhighlight %} {% include
|
|
|
|
docs/components/spacing-table.html values=page.customValues
|
|
|
|
shortcuts=page.customShortcuts directions=page.directions
|
|
|
|
horizontal=page.customHorizontal %}
|
2020-05-11 00:03:16 +00:00
|
|
|
|
|
|
|
<p>
|
2024-03-21 16:11:54 +00:00
|
|
|
By customizing the output, you've narrowed down the list of spacing helpers
|
|
|
|
from 112 to only <strong>18</strong>.
|
2020-05-11 00:03:16 +00:00
|
|
|
</p>
|