Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 4 - hidden classes - only hide on small screens

Tags:

How to hide span content only on small (sm) screens? I need this content visible on xs screens.

<span class="hidden-sm-down">Text</span> 

There is a way to do this using only bootstrap classes or not?

like image 350
Giorgio Fellipe Avatar asked Nov 07 '16 22:11

Giorgio Fellipe


People also ask

Which of the following classes should you add to hide an element on extra small screens less than 768 pixels and visible for all other screen sizes?

d-none d-md-block to hide on small and extra-small devices.


2 Answers

There is an upcoming update for Bootstrap 4 that will enable hidden on a single viewport (hidden-x)..

https://github.com/twbs/bootstrap/pull/22113

All of the visibility classes will be revamped in this update.


Update for Bootstrap 4 Beta

If you want to hide an element on specific tiers (breakpoints) in Bootstrap 4, use the d-* display classes accordingly. Remember xs is the default (always implied) breakpoint, unless overridden by a larger breakpoint.

https://www.codeply.com/go/bRlHp8MxtJ

  • hidden-xs-down = d-none d-sm-block
  • hidden-sm-down = d-none d-md-block
  • hidden-md-down = d-none d-lg-block
  • hidden-lg-down = d-none d-xl-block
  • hidden-xl-down = d-none (same as hidden)
  • hidden-xs (only) = d-none d-sm-block (same as hidden-xs-down)
  • hidden-sm (only) = d-block d-sm-none d-md-block
  • hidden-md (only) = d-block d-md-none d-lg-block
  • hidden-lg (only) = d-block d-lg-none d-xl-block
  • hidden-xl (only) = d-block d-xl-none

Demo of all hidden / visible classes in Bootstrap 4 beta

Also note that d-*-block can be replaced with d-*-inline, d-*-flex, etc.. depending on the display type of the element. More on the display classes in beta

like image 114
Zim Avatar answered Oct 28 '22 23:10

Zim


With Bootstrap 4 Beta 1, you can hide sm only with d-block d-sm-none d-md-block.

https://code.luasoftware.com/tutorials/bootstrap/bootstrap-hide-element-based-on-viewport-size/

like image 31
Desmond Lua Avatar answered Oct 29 '22 01:10

Desmond Lua