Bulma is responsive by default. Learn more about Bulma's responsiveness.
--- title: Responsive Mixins layout: documentation doc-tab: utilities doc-subtab: responsive-mixins fullmain: true breadcrumb: - home - documentation - utilities - utilities-responsive-mixins ---
Bulma is responsive by default. Learn more about Bulma's responsiveness.
Responsiveness in CSS is based on media queries (see MDN documentation).
Bulma provides 2 useful responsive mixins:
Their usage is very simple:
The from()
mixin has a single parameter which sets the screen width from which the styles it contains will be applied:
Sass source
{% highlight sass %}.my-element { background: red; @include from(1280px) { background: blue; } }{% endhighlight %}CSS output
{% highlight css %}.my-element { background: red; } @media screen and (min-width: 1280px) { .my-element { background: blue; } }{% endhighlight %}
For screens with a width of 1279px or less, the element's background will be red.
For screens 1280px-wide or more, the element's background will be blue.
The until()
mixin has a single parameter which sets the screen width (minus 1px
) until which the styles it contains will be applied.
This means that if you set a value of 1280px
, the styles will be applied on a screen width of 1279px
but not on a screen width of 1280px
.
The reason for this 1px offset is to allow you to use both from()
and until()
with the same breakpoint value. This leaves no gap between the 2 sets of rules.
Sass source
{% highlight sass %}$breakpoint: 1280px; .my-element { @include until($breakpoint) { background: green; } @include from($breakpoint) { background: orange; } }{% endhighlight %}CSS output
{% highlight css %}@media screen and (max-width: 1279px) { .my-element { background: green; } } @media screen and (min-width: 1280px) { .my-element { background: orange; } }{% endhighlight %}
For screens with a width of 1279px or less, the element's background will be green.
For screens 1280px-wide or more, the element's background will be orange.
By having 4 breakpoints and supporting 5 screen sizes, Bulma can support a lot of different setups.
These responsive mixins are named after the screen sizes and breakpoints used in Bulma, so that you can use them to create a responsive designs:
{{ breakpoint.name }} {% if breakpoint.id == 'mobile' %} Up to {{ breakpoint.to }}px
{% elsif breakpoint.id == 'fullhd' %}
{{ breakpoint.from }}px and above
{% else %}
Between {{ breakpoint.from }}px and {{ breakpoint.to }}px
{% endif %}
|
{% endfor %}
||||
---|---|---|---|---|
{% highlight sass %}{{ inc-mobile }}{% endhighlight %} |
- |
|||
- |
{% highlight sass %}{{ inc-tablet }}{% endhighlight %} | |||
- |
{% highlight sass %}{{ inc-desktop }}{% endhighlight %} | |||
- |
{% highlight sass %}{{ inc-widescreen }}{% endhighlight %} | |||
- |
{% highlight sass %}{{ inc-fullhd }}{% endhighlight %} | |||
- |
{% highlight sass %}{{ inc-tablet-only }}{% endhighlight %} |
- |
||
- |
{% highlight sass %}{{ inc-desktop-only }}{% endhighlight %} |
- |
||
- |
{% highlight sass %}{{ inc-widescreen-only }}{% endhighlight %} |
- |
||
{% highlight sass %}{{ inc-touch }}{% endhighlight %} |
- |
|||
{% highlight sass %}{{ inc-until-widescreen }}{% endhighlight %} |
- |
|||
{% highlight sass %}{{ inc-until-fullhd }}{% endhighlight %} |
- |
Learn more about Bulma responsiveness.