Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap3 .visible-* .hidden-* display inline

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!

like image 955
Augustin Riedinger Avatar asked Sep 30 '13 15:09

Augustin Riedinger


People also ask

Is display inline or block?

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.

What is display inline used for?

“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.

What is the opposite of display inline?

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.

What is an inline block?

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.


1 Answers

Update for Bootstrap v3.2.0

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> 

Other Instances

Asked about on Stackoverflow:

  • Bootstrap 3 class visible-lg moves span to a new line

Reported in Bootstrap Issues:

  • #4929 - Responsive utility classes may cause unexpected wrapping
  • #7808 - Using display inherit in responsive utilities causes elements to be wrongly displayed
  • #8500 - responsive class usage with inline element
  • #8869 - responsive .hidden-* classes change from display block to inline-block
  • #10263 - visible-xs makes display=block even for inline elements
like image 179
KyleMit Avatar answered Sep 21 '22 08:09

KyleMit