Bootstrap has some nice .visible-*
(eg. .visible-lg
) class utility for selecting what to show or hide depending on the screen size.
When using those classes, it applies the styling display: block !important;
when in the correct screen size.
But sometimes, I'd like to use it for some elements that are displayed inline
or inline-block
.
How could I cleanly override some bootstrap rules to have the choice? Or should it be a feature request in bootstrap?
EDIT
Seems like I'm not the only one wondering about this issue. Here's the github issue.
Thanks for the latest answer!
The display: inline-block Value Compared to display: inline , the major difference is that display: inline-block allows to set a width and height on the element. Also, with display: inline-block , the top and bottom margins/paddings are respected, but with display: inline they are not.
“display: inline” Property: This property is used to display an element as an inline element (like <span>). The height and width properties are not effected on display:inline; property. It allows only left and right side of margins, not top and bottom.
Now let's switched to the opposite of it, block . Remember inline elements appears on the same line. Well, block starts on a NEW line and takes up the full width available. So that means block elements will occupy the entire width of its parent element.
inline-block makes the element generate a block box that's laid out as if it were an inline box. According to QuirksMode: An inline block is placed inline (ie. on the same line as adjacent content), but it behaves as a 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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With