"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Hide Elements in Responsive Layouts with Bootstrap?

How to Hide Elements in Responsive Layouts with Bootstrap?

Published on 2024-12-21
Browse:318

How to Hide Elements in Responsive Layouts with Bootstrap?

Hiding Elements in Responsive Layouts with Bootstrap

When designing responsive layouts, managing space becomes crucial, especially on smaller screens. Bootstrap provides support for collapsing menu bar items for mobile devices, but what if you want to hide other page elements similarly?

Solution:

Bootstrap offers classes that allow you to hide elements based on screen size:

  • Extra Small Devices: Phones (
  • Small Devices: Tablets (≥768px) - .visible-sm-* (show), .hidden-sm (hide)
  • Medium Devices: Desktops (≥992px) - .visible-md-* (show), .hidden-md (hide)
  • Large Devices: Desktops (≥1200px) - .visible-lg-* (show), .hidden-lg (hide)

Example Usage:

To hide a .nav-pills element on small screens:

Additional Notes:

  • For Bootstrap 4, use hidden-*-up (hides for larger breakpoints) or hidden-*-down (hides for smaller breakpoints).
  • Bootstrap 3.2.0 deprecated .hidden-* in favor of .visible-*.
  • In older Bootstrap versions, .hidden-phone and .hidden-tablet are obsolete.
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3