Skip to content

Instantly share code, notes, and snippets.

@plugnburn
Last active March 16, 2017 00:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save plugnburn/0eea0b4ceb08c270efa6 to your computer and use it in GitHub Desktop.
Save plugnburn/0eea0b4ceb08c270efa6 to your computer and use it in GitHub Desktop.
999.css - a 999-byte barebones CSS framework
*{box-sizing:border-box;outline:none}
html {font-size:17px;font-family:Roboto,arial,sans-serif}
code,pre{
font-size:0.9rem;font-family:"Droid Sans Mono",monospace;
word-wrap:break-word;
}
body {margin:0;padding:0;font-size:1rem;line-height:1.375}
body,th,td,input,textarea,select,option,h1,h2,h3,h4,.fbox,.fr,.fr>*{
font-size-adjust:0.5;
font-family:inherit;
margin:0;
padding:0
}
a, a:link, a:visited, a:active {color:inherit}
.fbox,.fr,.fr>*{
display:block;
width:100%;
list-style-type:none
}
.hide{display:none}
h1{font-size:2em;line-height:1.25}
h2{font-size:1.625em;line-height:1.1538462}
h3{font-size:1.375em;line-height:1.13636364}
@media(max-width:699px){
.mob-hide{display:none}
}
@media(min-width:700px){
.mob-only{display:none}
.fr{display:table;table-layout:fixed}
.fr>*{display:table-cell}
.gsl{width:61.7283%}
.gss{width:38.2716%}
h1{font-size:2.5em;line-height:1.125}
h2{font-size:2em;line-height:1.25}
h3{font-size:1.5em;line-height:1.25}
}
.box{padding:1rem 2.5rem}
.nopad{padding:0}
/*colorscheme definitions - override at any time*/
.fcolor-main{color:#222;background:#ddd}
.fcolor-inv{color:#ddd;background:#222}
*{box-sizing:border-box;outline:none}html{font:17px Roboto,arial,sans-serif}code,pre{word-wrap:break-word;font:.9rem "Droid Sans Mono",monospace}body{margin:0;padding:0;font-size:1rem;line-height:1.375}body,th,td,input,textarea,select,option,h1,h2,h3,h4,.fbox,.fr,.fr>*{font-size-adjust:.5;font-family:inherit;margin:0;padding:0}a,a:link,a:visited,a:active{color:inherit}.fbox,.fr,.fr>*{display:block;width:100%;list-style-type:none}.hide{display:none}h1{font-size:2em;line-height:1.25}h2{font-size:1.625em;line-height:1.1538462}h3{font-size:1.375em;line-height:1.13636364}@media(max-width:699px){.mob-hide{display:none}}@media(min-width:700px){.mob-only{display:none}.fr{display:table;table-layout:fixed}.fr>*{display:table-cell}.gsl{width:61.7283%}.gss{width:38.2716%}h1{font-size:2.5em;line-height:1.125}h2{font-size:2em;line-height:1.25}h3{font-size:1.5em;line-height:1.25}}.box{padding:1rem 2.5rem}.nopad{padding:0}.fcolor-main{color:#222;background:#ddd}.fcolor-inv{color:#ddd;background:#222}

999.css

Looking for some ready CSS library under 1K to scaffold your markup on? Look no further.

999.css weighs 999 bytes minified (with devilo.us), and just 512 bytes gzipped.

For better impression of what it can do, please see the demo.

How to obtain

Download it here or include it right into your HTML:

<link rel=stylesheet href="//cdn.rawgit.com/plugnburn/0eea0b4ceb08c270efa6/raw/486682dbae8f05eef738bef3d6d7f69fcabcd048/999.min.css">

Usage

Originally started under "fungrid" name, 999.css borrows some ideas from different libraries like Ungrid, Gridism, Min.css, PocketGrid and Modernscale project, and combines them with own style to make a small and efficient tool.

Typography

Loosely based on Modernscale, somewhat simplified.

Headings are styled up to H3.

Just override html element font-size and font-family properties and watch the magic unfold. For monospace fonts, though, you'll have to modify the rules separately.

Default settings are:

html {font-size:17px;font-family:Roboto,arial,sans-serif}
code,pre{font-size:0.9rem;font-family:"Droid Sans Mono",monospace}

Grid

Mobile-first with a single breakpoint at 700px. The single class, fr, denotes a grid row. Any direct descendant of an fr-enabled element is a column. You can add as many columns as you like, and they are evenly auto-sized by default.

You can force a column width either with an inline style attribute, or with external CSS. However, 999.css has two classes for two special cases: gsl for larger golden section part and gss for smaller golden section part.

On mobile, all columns become just fluid 100%-wide blocks independent on their declared width (you'll probably not want to use inline styles for this case).

You can nest the grid rows as much as you want as long as you keep the correct ierarchy (i.e. you can't put a row directly inside another row, you must put a column first).

Element visibility control

Three classes are responsible for controlling element visibility:

  • hide - hide the element both on desktop and mobile;
  • mob-hide - hide the element on mobile while leaving it on desktop;
  • mob-only - show the element on mobile only and hide it on desktop.

Containers

A simple container box is supported with box class. By default, it's padded 2.5 rems from left and right and 1 rem from up and down. Feel free to customize the padding according to your needs. Note that 999.css already sets border-box as the default sizing model for everything.

If you don't need the padding on a particular container, just append nopad class.

Color scheme

999.css offers a very basic color scheme customization that allows you to provide just two colors - text and background - for two themes - main and inverted.

The fcolor-main class is responsible for main theme, fcolor-inv is responsible for inverted theme. Set one of them to any block to apply an appropriate coloring.

By default, fcolor-main provides #222 text on #ddd background, and fcolor-inv provides the opposite. Of course, you can (and generally should) override these classes however you want.

Browser support

Should run on anything that supports rem units and @media queries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment