1

I tried the below code for display in different ways in mobile and desktop. but both the sentences are displaying at the same time.

<div>
    <div class="hidden-xs hidden-lg hidden-sm visible-md">  
        Page-under-Construction.Please-try-again-later.  
    </div>  
    <div class="hidden-md hidden-lg visible-xs">  
        Page-under-Construction.  
    </div>
</div>  
Andy Costanza
  • 87
  • 1
  • 7
surya baby
  • 13
  • 2

3 Answers3

1

Use either hidden or visible (try not to use visible, see below), not both in the same class

Bootstrap Responsive Utilities

<div>
<div class="hidden-xs hidden-sm">  
    Page-under-Construction.Please-try-again-later.  
</div>  
<div class="hidden-md hidden-lg">  
    Page-under-Construction.  
</div>

edited: as pointed out below "visible" is now deprecated (see Drew Thomas' answer for explaination)

Vault Dweller
  • 135
  • 2
  • 10
1

Simple Sample

Also check this documentation from Twitter Bootstrap.

Visible to mobile only :

<div class="visible-xs">
    Content to show in mobile  
</div>  

Hidden to mobile only :

<div class="hidden-xs">
    Content to show in mobile  
</div>
jofftiquez
  • 7,548
  • 10
  • 67
  • 121
1

To expand on the other two answers:

  • Do only use hidden or visible on a single element (as mentioned)
  • Be aware that visible-* is deprecated now. Instead, there should be a display property at the end. An example is visible-md-block . See this thread: Hiding elements in responsive layout?

Here's a plunker using the code you provided: http://plnkr.co/edit/brjPCsh578WGu5Eq1rWl?p=preview

<div class="hidden-xs hidden-sm">
    Page-under-Construction. Please-try-again later.
</div>  
<div class="hidden-md hidden-lg">  
    Page-under-Construction.  
</div>
Community
  • 1
  • 1
  • do I need to change any settings in browser,for this purpose?bcz, the code works fine in plunker...but not in firefox in my system – surya baby May 08 '15 at 05:42
  • No problem. To be clear, visible itself is not deprecated, just without a display property at the end. The thread I mentioned has a thorough explanation. – Drew Thomas May 08 '15 at 05:42
  • @suryababy No, you shouldn't need to change a setting in your browser. My guess would be an issue with load order or having an older version of bootstrap. – Drew Thomas May 08 '15 at 05:47