Why the Bootstrap 3 Grid Works (2013)
helloerik.com
helloerik.com
* { box-sizing: border-box; }
This rule enables you to set a % width of a column and specify a padding in pixels without pushing the width of the columns beyond the 100%.
(I spent ages trying to replicate the bootstrap grid system and just couldn't get it to work until I discovered this rule!)
This then became the basis for CSS Wizardry Grids: http://csswizardry.com/2013/02/introducing-csswizardry-grids...
Example:
<div class="grid__item lap--one-half desk--two-thirds">
...
</div><!--
--><div class="grid__item lap--one-half desk--one-third">
...
</div>
What's the rationale for using inline-block instead of float?Using `display: inline-block;` allows you to manipulate grids with text-level properties (e.g. `text-align: center;` to cause grid items to fill out from the center of the row), and also allows you to use `vertical-align: [top|middle|bottom];` to cause columns to start from different, well, alignments.
[1] https://github.com/csswizardry/csswizardry-grids/blob/master...
[0]: https://www.ostraining.com/blog/coding/bootstrap-right-way/
This approach has helped me a lot in understanding how many of Bootstrap components work, and why they are structured the way they are :)
You think HTML5 is just about streaming video? The standards are out there and they are improving rapidly, look into flexbox.
All I'm hearing from you is "the gods will help us" when it would be better if W3C were smart enough to specify a sane bytecode and then let innovation run its course on top of that, instead of trying to predict our needs (which they've shown time and again they're bad at).
I wanted to explore foundation and uikit but always keep coming back to Bootstrap. It has proven an invaluable item in my toolbox. Its nice to understand the underlying reasons.
I've also been looking into http://purecss.io/ since it's grid is similar but the CSS package is lighter.
[0] - http://neat.bourbon.io/
What about creating silent classes for the column sizes you use and `@extend`ing those classes?
%three-columns {
@include span-columns(3);
}
.sidebar {
@extend %three-columns;
}
.menu {
@extend %three-columns;
background-color: #facade;
}Personally, if I am working quickly, I like having what amounts to a grid api exposed to my html and use it a lot, but I agree that it is better if it doesn't have to be baked into the markup.
They have since shifted to "make a CSS framework that can actually be used by other people, while still staying under 995 bytes". I also got another person (Scott O'Hara, https://github.com/scottaohara) to contribute; he made several useful contributions and also made size optimizations. As a result, Min 2.0 will be 995 bytes and also include a (clearly superior) 12-column grid. It will also include many other useful features, like a better responsive navbar and better icons, include all of Bootstrap's features, and it will still support IE5.5+.
It'll be nice when you can assume full support but I'll take vertical centering, easily consistent heights across elements, etc. now.
/personal opinion
There are smaller grids, simpler grids, etc, but none are as robust and generalized as Bootstrap/Foundation. These have to be as close to "one size fits all" as they can.
I personally dislike them because CSS classes should specify what an element is rather than what it will look like. e.x. if HN were to change from tables to CSS they would use .topbar { background: #ff6600; } instead of .orange { background: #ff6600; } That said, I made a CSS framework [0] that does things differently so I am somewhat biased.
For lightweight grids that support dynamically sized containers, masonry was great. But there a ton of issues with keeping the content centered when the container changes size.
We dealt with this by using inline-blocked elements with tex-align: center, then appending invisible elements to maintain an apparent left-oriented grid: https://github.com/hangify/Central
Try replicating Min's navbar quickly (the v2.0 one) and you will end up with tons of compatibility problems, strange bugs, and you'll give up quickly. There's a reason there are only five CSS frameworks (Bootstrap, Foundation, uikit, Ionic, Min) that actually have a working navbar. That's out of about 100 CSS frameworks total. All of those five frameworks, except Min, have a company, thousands of stars, and tons of contributors behind them.
I don't count Gumby as its navbar has some weird bugs, plus it uses display: table. I don't count Cascade and Ink as neither work consistently on Android.
For a preview of Min 2.0, try http://pasteht.ml/Rg0B0
My focus wasn't on the bootstrap CSS customizer though, I try to recommend people use their own Less to keep things under control.
If you need multiple bleeds on a page, use multiple containers. Just don't nest containers inside of containers.
For images that you want to touch the side or whatever, there is some of that fiddling with the margins on the interior elements, yeah.
Personally, I use the SASS build, include only the most basic parts (scaffolding, type, grid, ...), customise the hell out of the variables, and you'd never know it was bootstrap. For reference, http://www.recruiteasy.com.au is a bootstrap-based site, using standard breakpoints.
[1] http://getbootstrap.com/customize/
@media (min-widht: @eriks-custom-width); {}
That syntax is off but you get the gist.
Most of his posts get lots of thoughtful comments, and presumably high powered links. I would assume this level of engagement+backlinking helps quite a bit with his search ranking.
I wrote the explanation above. Just good content on a topic that gets a ton of searches, but a lot of people don't write about it in clean, understandable ways. At the time, the Bootstrap doc didn't explain it in the same amount of detail. Now that google recognizes the content and the backlinks and social proof via HN, Twitter, etc, it's just on a snowball. It's at about 50k visitors a month, mostly from Stack Exchange and Google organic searches.
Once a blog gets a few top 3 ( and a few #1) hits in a google search, it just snowballs. I consistently get more and more visitors each day, more retweets, etc etc. Like after today, my average visitor count will jump up and then stabilize at a much higher average than yesterday, since once content like this that is instructional makes waves, people just link it and tweet it exponentially and it never dies off. Really crazy how useful content and targeted organic SEO can work.
It's legit ground-up SEO and content success, no magic. And, it helps that no one has ever tried to write Bootstrap articles and explanations like I did in my 3 articles.
BTW I am the author if that's not obvious =D
The -15px margin on the rows and 15px margin on the columns would still do their job, only that the rows would be 15 pixels smaller.
The big problem comes when your project is big enough that you stop relying on the default CSS, and need to switch over to a full SASS pipeline incorporating their stuff. Lot to do.