A bit more responsive
Hello,
I am fiddling a bit around with the responsive approach in Bootstrap. Are there any plans or idea's (or am I not aware of the ability) to say something like "4 columns" on desktop size. "3 columns" on tablet size. And/or to say the sidebar for instance is just informative, it should be hidden when seeing the site on a mobile device.
I am creating something like this now but I was wondering if this community had such a thing in the planning or you have idea's what the best way is to build it? Any feedback is welcome.
Example 1 (4 columns on desktop, 3 on tablet)
<div class="span3 portrait-span4">one</div>
<div class="span3 portrait-span4">two</div>
<div class="span3 portrait-span4">three</div>
<div class="span3 portrait-span12">four</div>
Example 2 (2 columns on desktop, 1 on tablet)
<div class="span8 portrait-span12">main</div>
<div class="span4 portrait-hidden">side</div>
CSS
@media (min-width: 768px) and (max-width: 980px) {
.portrait-hidden{
display:none;
}
.portrait-span12, .portrait-container {
width: 724px;
}
.portrait-span4 {
width: 228px;
}
}
At first, I wanted that model too, because it seems to make responsive features more 'automatic': set columns once, let them adjust automatically for every layout, and only tweak the ones misbehaving. However, I later figured out that this means a lot of tweaking; for example, 5-column element would need to be tweaked to (say) 4 on layout A, and then to 3 on layout B. Since Bootstrap already uses LESS, I find it easier to take the other approach and define my layout elements in each responsive category, and set their columns there. You can still use the old approach if you want, though.
Also, columns rarely work as expected on very small screens (the ones where bootstrap goes fluid), so that really means you only need to accomodate for three layouts anyway.
For example:
@media (max-width: 786px) {
article {
width: 100%;
// accomodate for fluid here
}
}
@media (min-width: 768px) and (max-width: 980px) {
article {
.span8;
}
}
@media (min-width: 1200px) {
article {
.span8;
// other adjustments
}
}
The drawback is, however, it's hard to predict what size a particular element will be at any given point, given the varying grids. One would have to manually calculate that from the grid size and column span, which is annoying.
Nope, I don't think we'll be including this any time soon. Thanks for the suggestion though!
Thanks Mark, Can I have a go with this and try submitting a pull? Or don't you think it's an addition for bootstrap?