• Stars
    star
    475
  • Rank 92,070 (Top 2 %)
  • Language
    CSS
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple CSS grid system using `display: table;`.

Table Grid

Every grid to date uses floats or some inline-block hackery. That's so 2013 though, and seeing that it's now 2014, we need something newer, faster, and stronger. So, Table Grid was born.

Check out the example on GitHub Pages at http://mdo.github.io/table-grid/. Clone this or download it to give it a whirl for yourself.

Wtf

This isn't a serious project really, it's just an experiment. I'm curious about the rendering performance of using display: table; as opposed to floats, flex-box, or display: inline-block;. Each option has pros or cons, but in particular I'm focused on the con part:

  • floats require clearing and I have zero idea about rendering performance. They're straightfoward and Just Workâ„¢.
  • flex-box has poor rendering last I heard because browsers have to do a lot of repainting to support it. I have no references to this, it's what I've heard. Plus, browser support and what not.
  • display: inline-block; is gnarly because it involves resetting white-space and that's just silly. We shouldn't be resetting that kind of stuff just for a grid system.

So, based on that, display: table; starts to sound kind of interesting. Table layouts, especially ones that include table-layout: fixed; render super fast because browsers only need to render the first row of cells to paint the whole table. That's kind of moot with one row grids like this, but it might help anyway.

How it works

As always, there's a container, row, and a series of columns. It's responsive, too. More specifically:

  • Center the site contents with .container, which has a max-width: 940px;.
  • Wrap a row of columns with .grid. This sets up the table-based grid with display: table;, width: 100%;, and table-layout: fixed;.
  • Columns get the .col base class and an optional width class, like .col-1 or .col-6. There are 12 available column classes, 1-12, for any variety of column combinations.
  • Grid width class is not required. Without them, all columns become equal width via .col alone. Tables, baby!
  • Grids are nestable—just place a new .grid within any .col. Bam.
  • By default, because of how display: table; works, there's no gutters. To add gutters, wrap the .grid in .grid-padded, which adds gutters with border-spacing: 1rem 0;. Sucks, but this is experimental.

All this can be seen in action on the demo page.

What's included

Table Grid has been rebuilt to use Sass (thanks, Jekyll!). Key CSS bits are broken down in _sass:

  • grid-basics.scss contains the container and basic responsive, equal-width column support.
  • grid-columns.scss contains specific column width classes for more granular control (e.g, .col-6 is 50% wide).
  • grid-extras.scss is for alignment and sorting options.

See http://mdo.github.io/table-grid/ for details on usage.

Fuck you, where's the real grid?

If you need a nuclear hardened grid system, check out Bootstrap. It's okay.

License

MIT, (c) Mark Otto 2014.

More Repositories

1

code-guide

Standards for developing consistent, flexible, and sustainable HTML and CSS.
SCSS
8,458
star
2

github-buttons

Showcase the success of any GitHub repo or user with these simple, static buttons with dynamic counts.
JavaScript
2,851
star
3

wtf-forms

Friendlier HTML form controls with a little CSS magic.
CSS
2,693
star
4

preboot

A collection of LESS mixins and variables for writing better CSS.
CSS
1,677
star
5

wtf-html-css

Common reasons your HTML and CSS may be fucked.
CSS
1,407
star
6

config

Personal checklist for setting up a new Mac's dev environment.
Shell
618
star
7

css-perf

**Archived.** Derping around with measuring CSS performance.
HTML
572
star
8

jekyll-snippets

Library of commonly used snippets for Jekyll sites.
552
star
9

github-wide

Userstyle for making all of GitHub completely fluid.
CSS
497
star
10

ocean-terminal

An OS X Terminal.app profile based on the base16 Ocean theme.
413
star
11

mdoml

An experiment in creating custom HTML elements based on today’s most common interface elements.
CSS
174
star
12

sublime-snippets

Custom snippets for Sublime Text 2
153
star
13

twitter-userstyle

Bring the aesthetic of Twitter for iOS to the new Twitter.com.
CSS
139
star
14

jekyll-example

Example Jekyll site with basic defaults and Sass enabled.
CSS
132
star
15

bsu

Bootstrap University is a hands-on code lab specially designed to familiarize you with building on the Web with Bootstrap by quickly taking you through building an example page with the latest beta version of Bootstrap 3.
CSS
87
star
16

bootstrap-css-grid-layout

Attempting to rebuild Bootstrap's grid in CSS Grid Layout.
CSS
57
star
17

css-output

Comparing the differences in compiled CSS when using different Sass/Less methods to build reusable components.
CSS
57
star
18

mdo-df-css

Custom user style that overhauls the default CSS for daringfireball.net to increase readability.
CSS
41
star
19

minecraft

Links, resource packs, and more for my Minecraft setup.
Shell
31
star
20

dotfiles

Shell
17
star
21

userstyles

Customizations and enhancements for sites and app I love most.
CSS
12
star