GithubHelp home page GithubHelp logo

mdo / table-grid Goto Github PK

View Code? Open in Web Editor NEW
474.0 28.0 46.0 29 KB

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

Home Page: http://mdo.github.io/table-grid/

License: MIT License

CSS 87.26% HTML 12.74%

table-grid's Introduction

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.

table-grid's People

Contributors

hiisi13 avatar ianrose avatar mdo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

table-grid's Issues

Scss support

Hi, I'm a little experimenting with display: table
And it's really cool stuff that lets you do a lot of interesting things.
I think of in order to make a complete analog bootstrap grid on scss and then the other preprocessor I think it should be very interesting.
How do you like the idea?

"Tables are super impractical for grids ...

"Tables are super impractical for grids because there is no perf gain when using table-layout: fixed;, a property that tells the browser to only scrape a table's first row of cells to determine every cell's width for super fast rendering." – css-perf

I'm wondering why you say they're "super impractical", yet you have this project here. I've been using CSS tables for layout for years, and I haven't found them to be bad at all. Could you explain you reasoning?

Great !!!

Great! A full complete grid with just a few line of css.

However you must be clean in the example that you have only 2 possibile use:

a) the template: 1, 1, 1, 1, 1 on mobile (600px)
b) the grid on large then 600px

using table i don't think you can have different breakpoints at custom size, isn't it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.