{Carrer web log} ←
1 line CSS Grid Framework
Tuesday, June 02, 2009 { 48 Comments }
This is the challenge of writing entire CSS layout system with one line CSS class.I just wanted to prove how easy CSS can be, and with little imagination we can be build cool things.
I started with the principle that every column can be divided by two, becoming half column or 50% column.
So how can we build CSS Layout system with this principle?
One column can become 2 (50%) column or 100% = 50% + 50%.
So we can make 2,4,8,16, … layout system.
Believe it or not we only need this line of CSS code:
.dp50 {width:50%; float:left; display: inline; *margin-right:-1px; }
A little explanation:
.dp50 means div 50 percent
and we have floated left 50% column, display: inline; *margin-right:-1px; is fix for IE.
So the result is:
Download link
The system can be made to work with any main default size(px, em, %) something like 950px or 550px or 90% or 50em. This system works even in IE5.5, so you don’t have problem of multi browser compatibility.
You can use the system in many different ways.
Limits of this Framework?
The main limit is that you can use only 1,2,4,8,16 columns system plus some combinations like (50% + 25% +25%). If you have something like 16 columns you will have many nested divs.
Conclusion: This is just technical demo and I don’t advise you to use it in production. If you need something very small you can use Malo, it is just 8 lines of code and uses the same naming system but has to offer much more.
Building some "real" css layout system(CSS Framework) is much more complex work. Usually you project your layout starting with the typography . On the base of the typography you make the grid and the gutter.
I spend a lot of time searching for the best gutter or perfect web grid and searching the answer to the question "how we read?".
So I repeat, this experiment has pure technical nature of building relatively complex css layout with minimum CSS code.
48 Responses to “1 line CSS Grid Framework”
- // Simple // 6/02/2009
- // Pär Thernström // 6/02/2009
- // jrosell // 6/02/2009
-
// Vladimir
// 6/02/2009
@jrosell: You can use Malo the same css syntax but more options.
- // Stanley // 6/02/2009
- // Unknown // 6/02/2009
- // test // 6/02/2009
- // Netwala // 6/02/2009
- // // 6/02/2009
- // Niceoutput // 6/02/2009
- // Tyler Diaz // 6/02/2009
- // jrosell // 6/02/2009
-
// Vladimir
// 6/02/2009
@jrosell: If you need something complete with all options you can use Emastic (inside plugins there is percent-grid.css). Inside there are almost all combination from 10% to 100%
- // Jan Järfalk // 6/02/2009
- // aApe // 6/02/2009
- // Unknown // 6/02/2009
- // Vladimir // 6/02/2009
- // Dan // 6/02/2009
- // delfuego // 6/02/2009
- // Vladimir // 6/02/2009
- // // 6/02/2009
-
//
// 6/02/2009
The only problem I see with this solution (and this is true with many CSS frameworks) is that all the spacing like margins and paddings have to be added to content inside the divs. If you add any padding to the 50% div its width will be more than 50% and you'll end up with float drops. So, if you want 15px margin between columns, you have to add margin to each tag in the div--too much redundancy for me.
-
// Vladimir
// 6/02/2009
@MyID.php(dave): The solution is very simple: p{padding:0 14px 0 0;}
You always have paragraphs (p) indie div. So you can use divs like building blocks.And paragraphs for text,images and everything else.
Look at the code: Example 3 - // Crantea Mihaita // 6/02/2009
- // Ashton Sanders // 6/03/2009
- // // 6/03/2009
- // // 6/03/2009
- // Andrea Giammarchi // 6/03/2009
-
//
// 6/03/2009
It would be nice if it wouldn't be build mostly of CSS hacks.
Float property were never meant to build columns - you should use 'inline-block' instead.
Other thing, you say to browser to display block elements as inline - this may lead to very unpredictable behavior in many browsers (of course in IE it will work "right" ;-) - // Ramon Leon // 6/03/2009
-
// Vladimir
// 6/03/2009
@Ramon: Don't kill the messenger! I didn't invent the name. I prefer calling it CSS Library. But the naming standard now is CSS Framework.
The word CSS Framework was invented by Jeff Croft and I wrote my opinion on Jeff's blog
In my opinion CSS Framework(Library) is making high level reusable CSS code.
CSS is Not programing language so any association with other programing Frameworks is wrong.
One true thing about word Frame-work and CSS you are always "inside the"frame" and if you want something specific you must write your CSS code. -
//
// 6/03/2009
"And paragraphs for text,images and everything else"? Seriously? Yecch!
I admit this is cool, and proves you can tackle difficult layouts with a minimal amount of CSS, but why not use paragraph tags for paragraps, image tags for images (see where I'm going with this?), etc? God gave us those tags, let's use 'em!
Still, neat trick :) -
// Vladimir
// 6/03/2009
@Anonymous: I'm not sure what is your point? Are you suggesting one column web site with only use of paragraphs and images? No tables, no divs, no flash,no videos. Maybe I did Not understand your point.
If I did you definitely going to like this: One div and many paragraphs :)
Better Web Readability Project - // HoyaBaptiste // 6/04/2009
- // Bung Iwan // 6/05/2009
-
// Mark Gardner
// 6/05/2009
I think this is absolutely brilliant. I love Malo too...I will find a way to implement one them on my next newsflash sites. I've been dropping some cool newzy sites all over the place actually I have them rotating on my hosting with using a dynamic IP so it's pretty random. I dunno I just enjoy using the web in a different way. It's cool to be able to drop a newzy site with some cool info on it and then have it drop and change to another newzflash after a few clicks. This looks perfect for this. Thanx.
- // SharePoint Guy // 6/07/2009
- // Johns Beharry // 6/09/2009
- // Color Printing // 6/20/2009
- // // 7/26/2009
- // Eken Et // 10/24/2009
- // grid // 2/26/2010
-
// Caravan Guy
// 6/20/2010
The best ideas are always the simplest. The main argument against other grid systems is bloat, they try to do too much. With Google WMT speed analysis pushing us to reduce all file size if we are to adopt a css grid it needs to be small. The only downside is now I want to go and redo my latest Blueprint based site using one of your small frameworks.
Many Thanks! - // Philippines Outsourcing // 7/30/2011
- // // 12/03/2011
- // Surya Adi Saputra // 12/14/2011
- // Adam Kochanowicz // 3/16/2012
- // Vladimir // 3/16/2012
<< Home
About Me <<<
Name: Vladimir Carrer
vladocar [at] gmail.com
Location: Verona, Italy
I'm a web designer, developer, teacher, speaker, generally web addicted ...
My projects <<<
- AI Prompt Directory
- Hand Drawn Icons
- Font Design Inspiration
- Font Pairings
- Free SVG Cut File
- Upcoming NFT projects
- Discord Tutorials
- Free Sublimation Designs
- Tech Feed
- MySQL Lite Administrator
- Quark Mini PHP CMS
- Formy - CSS Form Framework
- Emastic - CSS Framework
- Malo - CSS Library
- The Golden Grid
- 1 line CSS Grid Framework
- Two Lines CSS Framework
- Child Selector System - CSS Framework
- Better Web Readability Project
- Azbuka - CSS Typographical Base Rendering Library
- ClipR - bookmarklet for better reading
- CSS3 Action Framework
- CSS Mini Reset
- HTML5 Mini Template
- CSS Mobile Reset
- picoCSS - JavaScript Framework
- HTML Lorem Ipsum Crash Test
- Object Auto Documentation - JavaScript
- o - JS Library for Object Manipulation
- Foxy - CSS Framework
- Tumblr Free Theme - Better Readability Project
- Box - CSS Framework
- SMART CSS GRID
- nanoJS - Minimal JS DOM Library
- Flexy CSS Framework
- Katana is CSS Layout System made with Flexbox
- Micro CSS Reset
- 60 Grid System
- Simple CSS Button
- ramd.js JavaScript library for making web applications.
- Minimal Notes web app build with Vue.js
- Scribble Font for Prototyping & Wireframing
- Flex One - 1 CSS Class System
- Floaty - CSS Float Based Layout System
- Infinity CSS Grid
- CLI Convert websites into readable PDFs
- keywords-extract - CLI tool, extract keywords from any web page.
- screenshoteer - Make website screenshots and mobile emulations from the command line.
- Basic.css - Classless CSS Starter File
§§Previous Posts <<<
- O rule + golden proportion for calculating the gut...
- How we read on web and how can we improve that
- Geo Twitter (#ll)
- Handcrafted CSS + HTML Grid Calendar 2009
- Is it time to move beyond 960? Not yet
- Twitter Compressor
- The Twitter is not about you, it is about the comm...
- Google redesign (Google in a grid)
- F pattern or just simple triangle
- The Golden Grid
Other Profiles <<<
Content is licensed under a Creative Commons Public Domain License