I have a site with 2 columns and i want to hide one of the columns when the site is viewed on a mobile. I know you can use the hidden_phone class and set the column class to 99% or whatever it is using a screen size media query but im wondering if this is the correct way of doing it. Is there a better way or a more correct way
<div class="container> <div class="row"> <div class="span8">some content</div> <div class="span4 hidden-phone">some content</div> </div> </div> @media (max-width: someresolution){ .span8{ width:99.3214534%; } }
To hide elements simply use the .d-none class or one of the .d-{sm,md,lg,xl}-none classes for any responsive screen variation.
By using col-lg-push and col-lg-pull we can reorder the columns in large screens and display sidebar on the left and main content on the right.
Bootstrap. The world's most popular mobile-first and responsive front-end framework. Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile first projects on the web.
So you can use d-none-* (hide) to any element, but to display element d-*-block only work in a wrapper element like div. I hope it help.
Yes, this is actually the approach twitter bootstrap uses. Have a look at the source code of their grid system.
The hidden-phone, ... classes (these have been renamed to hidden-xs, .. in version 3) work by just setting the "display" attribute to "none" or "block" depending on the current media query. Have a look at their responsive-utilities and mixins and look for the text 'responsive-visibility' if you want the full details.
While this is 'less' and not 'css', it should be readable. If you're curious what 'less' is, visit the website at lesscss.org
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