Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inline objects becomes block while using some (hidden-xs) classes in twitter-bootstrap-3

BOOTPLY HERE

I try to make some buttons text hidden to make them smaller for xs screen size.

<button class="btn navbar-btn btn-primary">
    <i class="fa fa-font"></i>
    <span class="hidden-xs">Add Text</span>
</button>

There is no problem with element hiding but now span makes my button 2 rows. Is there any way to solve this problem.

Or is there any better approach to hide button texts in bootstrap?

enter image description here

For the ones who still has the same problem

If you are using bootstrap 3: http://getbootstrap.com/css/#responsive-utilities

<button class="btn navbar-btn btn-primary">
    <i class="icon-picture"></i>
    <span class="visible-sm-inline visible-md-inline visible-lg-inline">Add Image</span>
</button>

If you are using bootstrap 4: http://v4-alpha.getbootstrap.com/migration/#responsive-utilities

<button class="btn navbar-btn btn-primary">
    <i class="icon-picture"></i>
    <span class="hidden-xs-down">Add Image</span>
</button>
like image 788
effe Avatar asked Dec 30 '13 11:12

effe


People also ask

What is hidden Xs in bootstrap?

<h1 class="hidden-xs bg-danger">This text is hidden on an EXTRA SMALL screen.</ h1> <h1 class="hidden-sm bg-info">This text is hidden on a SMALL screen.</ h1> <h1 class="hidden-md bg-warning">This is text hidden on a MEDIUM screen.</

What is D inline-block in bootstrap?

d-inline-block to simply set an element's display property to block , inline , or inline-block (respectively). To make an element display: none , use our responsive utilities instead. Inline. Inline. <div class="d-inline bg-success">Inline</div> <div class="d-inline bg-success">Inline</div>

What is inline-block?

One common use for display: inline-block is to display list items horizontally instead of vertically.

What is hidden Md down?

hidden-md-down hides an element on extra-small, small, and medium viewports. There are no explicit “visible”/”show” responsive utility classes; you make an element visible by simply not hiding it at that breakpoint size. You can combine one .


1 Answers

Since Bootstrap 3 uses..

.hidden-xs {
    display: block !important;
}

You need to do this..

.navbar-btn .hidden-xs {
    display: inline-block !important;
}

@media (max-width: 767px) {
.navbar-btn .hidden-xs {
  display: none!important;
 }
}

to override the block display of the xs span.

http://bootply.com/103026

like image 166
Zim Avatar answered Sep 22 '22 15:09

Zim