• Stars
    star
    1,468
  • Rank 32,033 (Top 0.7 %)
  • Language
    CSS
  • License
    Other
  • Created about 8 years ago
  • Updated almost 8 years ago

Reviews

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

Repository Details

Fukol Grid System

Fukolâ„¢ is a lightweight, breakpoint free, completely responsive, element query driven*, progressive enhancement based CSS grid framework. It exists in this README.md file, in the section titled The CSS (below). It is 93 bytes minified, fitting comfortably inside a tweet:

Fukol minified and in a tweet

Just edit the lines marked 'edit me!' to your requirements and write an HTML structure like the one illustrated in the section titled The HTML (also below).

(* Not really, but kind of. See 3 under Notes, below.)

The CSS

.fukol-grid {
  display: flex; /* 1 */
  flex-wrap: wrap; /* 2 */
  margin: -0.5em; /* 5 (edit me!) */
}

.fukol-grid > * {
  flex: 1 0 5em; /* 3 (edit me!) */
  margin: 0.5em; /* 4 (edit me!) */
}

The HTML

<div class="fukol"> <!-- 6 -->
  <ul class="fukol-grid">
    <li><!-- grid cell/item/child/whatever --></li>
    <li><!-- grid cell/item/child/whatever --></li>
    <li><!-- grid cell/item/child/whatever --></li>
    <li><!-- grid cell/item/child/whatever --></li>
    <li><!-- grid cell/item/child/whatever --></li>
    <li><!-- grid cell/item/child/whatever --></li>
    <li><!-- grid cell/item/child/whatever --></li>
    <li><!-- grid cell/item/child/whatever --></li>
  </ul>
</div>

Notes

  1. Fukolâ„¢ is a Flexbox based grid system. Even Opera Mini supports Flexbox. Older user agents that don't support Flexbox ignore the display: flex declaration, degrading to a single column layout. No harm done.
  2. This line determines how items are handled. The wrap value means items will start a new row if there's not enough room on the current one.
  3. This is the 'element query' part. Instead of setting an arbitrary number of columns and using breakpoints, we decide roughly how wide we want the item to be (5em in the example — the flex basis) and make sure items can grow to use the available space (1) but not shrink (0). So only change the 5em value and leave 1 0 as it is.
  4. This is for gutters. A 0.5em margin here means gutters of 1em (the margins double up).
  5. This should always be a negative version of 4. It compensates for the margins created by the items. It makes sure the outside of the .fukol-grid container remains flush horizontally and no additional margin is added to the vertical flow.
  6. The class="fukol" container in the HTML snippet enables you to add positive margins around the grid — not possible with just .fukol-grid because this uses negative margins (see 5). It also suppresses horizontal scrolling issues which occur under certain circumstances.

Demos

Here's a gif

Grid items as boxes, collapsing into fewer columns at smaller viewports automatically

Play around on CodePen

codepen.io/heydon/pen/dpzwVd

Items with different widths

Sometimes you want certain items to be narrower or wider. Maybe you want the fifth item to always be approximately twice the size of a regular item (where space permits). If the regular flex-basis is 5em, then…

.fukol-grid > *:nth-child(5) {
  flex-basis: 10em;
}

Don't worry, flexbox will make sure there aren't any gaps.

Percentage widths

You can choose a percentage based width for individual items, but remember to adjust for the gutter margin width by subtracting it using calc. For example, to make the first item 100% in width when the gutter width is 1em, use:

.fukol-grid > *:first-child {
  flex-basis: calc(100% - 1em);
}

Warning: Internet Explorer does not respect box-sizing on flex-basis items. In which case, if you use percentage widths, you cannot pad the flex item directly. You will need to insert child nodes inside flex items and pad them instead.

<div class="fukol"> <!-- 6 -->
  <ul class="fukol-grid">
    <li>
      <div><!-- pad this --></div>
    </li>
  </ul>
</div>

RTL Grids

Flexbox supports rtl already. Just add dir="rtl" to the .fukol-grid element and the flex direction will automatically be reversed.

FAQs

  1. How do I install Fukolâ„¢? Is it on bower/npm? You install it by copy/pasting it from this README.md file. See the The CSS section above.
  2. How do I pronounce Fukol? Fukol is pronounced "the square root of fuck all".
  3. Is Fukolâ„¢ the answer to all my grid system hopes and dreams? No. Fukolâ„¢ is just a servicable solution, written with very little code.
  4. Why are there a load of old dicks in the Fukolâ„¢ logo? Are you some sort of misogynist? No, fuck the patriarchy. There are a load of old dicks in Fukolâ„¢'s logo because grid systems are a load of old dicks.
  5. Is there a Sass version? Yes: inside your head.

That's it

That's it.

More Repositories

1

inclusive-design-checklist

Aims to be the biggest checklist of inclusive design considerations ever
JavaScript
2,713
star
2

REVENGE.CSS

A CSS bookmarklet that puts pink error boxes (with messages in comic sans) everywhere you write bad HTML.
CSS
828
star
3

forceFeed

JavaScript
518
star
4

bruck

A prototyping system built with web components and the Houdini Paint API
JavaScript
511
star
5

watched-box

JavaScript
327
star
6

Community-Icon-Font

To create a collaborative font using SVG
196
star
7

inclusive-menu-button

A keyboard and screen reader accessible ARIA menu button implementation.
JavaScript
191
star
8

design-tokens-cli

Set of design tokens and a custom properties parser for prototyping
JavaScript
173
star
9

cel-animation

A Sass @mixin for creating traditional frame-based animations, especially with SVG
CSS
155
star
10

beadz-drum-machine

A quantum, polymetric drum machine.
Vue
141
star
11

on-demand-live-region

JavaScript
128
star
12

ga11ery

Eleventy theme for showcasing photography and web comics
HTML
97
star
13

cress

JavaScript
83
star
14

readabilityCheckerCLI

A node CLI for checking how readable content is. Accepts a URL or HTML file.
JavaScript
70
star
15

xiao

A tiny, accessible, browser-driven single-page routing system.
JavaScript
56
star
16

react-sortable-table-demo

See the article here: https://inclusive-components.design/data-tables
JavaScript
40
star
17

css-scopulation-enterprise-max-ai

JavaScript
29
star
18

react-theme-switch

JavaScript
27
star
19

Inclusive-Components

Resources for the inclusive components blog (inclusive-components.design)
26
star
20

css-error-property-style

18
star
21

wai-aria-web-component

A "disclosure" (show/hide) web component using ARIA and built with Polymer
CSS
13
star
22

inclusive-inline-editable

JavaScript
9
star
23

buttonlike

A jQuery plugin for making clickable elements more accessible
JavaScript
8
star
24

typical-theme-wordpress

A responsive, resolution independent Wordpress theme with microdata support
CSS
8
star
25

AMA

Ask me anything
6
star
26

Squib-Font

A free font licensed under the Open Font License
6
star
27

heydonworks

HeydonWorks Wordpress theme
CSS
3
star
28

Accessible-Designer-Examples

Examples of creative, accessible design concepts.
HTML
3
star
29

ga11ery-michael

HTML
2
star
30

ga11ery-example

HTML
2
star
31

niace-stories-app

The alpha application for NIACE.
JavaScript
1
star
32

Redfoir

Freedom of Information Timeline Project
JavaScript
1
star