Bootstrap has some nice .visible-*
(eg. .visible-lg
) class utility for selecting what to show or hide depending on the screen size.
When us
Updating to bootstrap 3.1 or above indeed solves the problem as from this point on the hidden-
classes only hide the tag and don't set display: block
anymore. This way you can use <div>
for block context and <span>
for inline-block context (the normal behavior of these tags)
This has been sort of fixed in v3.1.
.visible-lg
or .visible-md
will force display: block !important;
but using .hidden-xs
or .hidden-sm
will display inline.
The following library extends the visible helper classes with inline & inline-block variations:
https://github.com/moappi/bootstrap.inline-responsive
Implements the following:
visible-inline-*
hidden-inline-*
and
visible-inline-block-*
hidden-inline-block-*
This is now natively solved in Bootstrap v3.2.0 with this commit
According to the new responsive classes documentation:
As of v3.2.0, the .visible-- classes for each breakpoint come in three variations, one for each CSS display property value listed below:
Group of classes | CSS display
.visible-*-block | display: block;
.visible-*-inline | display: inline;
.visible-*-inline-block | display: inline-block;
For example, you could use:
<p>Device is: <span class="visible-lg-inline">Large</span></p>
Asked about on Stackoverflow:
Reported in Bootstrap Issues: