Object Oriented CSS
github.com
github.com
Link is available on the FAQ wiki page - it should really be on the readme.
edit: I don't think I like it... some details as to why:
grid.css
.line:after, .lastUnit:after {
clear: both;
content: " x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x ";
display: block;
font-size: xx-large;
height: 0 !important;
line-height: 0;
overflow: hidden;
visibility: hidden;
}
Anyone care to explain that one? Disabling it causes some sections of the page to overlap. grid.css
.size1of1 {float: none;}
.size1of2 {width: 50%;}
.size1of3 {width: 33.3333%;}
... etc
content.css
.f105 {font-size: 105%;}
.p0 {padding: 0;}
.p15 {padding: 15px;}
.pt0 {padding-top: 0;}
.pt25 {padding-top: 25px;}
.pl0 {padding-left: 0;}
.pl15 {padding-left: 15px;}
... etc
They've achieved "object oriented" by moving the styles from the CSS to the class attribute. ie, you might as well write `style="padding:0"`, it's the same thing. No doubt HTML-veterans who never really got the whole CSS thing would like it, it's very nearly equivalent to using tables for layout, but with floats instead of <td>s.That said, I have not used it, or any similar CSS frameworks. Anyone who has care to comment on usability / reusability?
Though I would be interested in seeing some profiling data demonstrating one way or the other. Even if it's relatively transient data, as it relies heavily on the rendering code.
http://www.stubbornella.org/content/2010/12/09/the-hacktasti...
Edit: I also agree with your sentiment. This seems to move away from what CSS classes are intended for, and gives things naming conventions that are tied directly to their internal CSS code instead of to their semantic meaning on the page. That said, I haven't used it either, so maybe it's way better this way, but something doesn't sit right with me.
var foo = new Animal Brown Quadruped Barking();
Even if styles could be inherited, this seems to be taking the wrong approach. Most of use realise that classes should be used to denote identity, and not behaviour (or in this case, styling). CSS preprocessors seem to fix the same problem in a much nicer way. /* Define classes used in HTML */
.sidebar {
@include bordered-box;
}
#special-offer {
@include bordered-box;
position: absolute;
top: 0;
right: 0;
}
/* Define theme information */
@mixin bordered-box {
h3 {
background: red;
color: white;
}
border: 1px solid red;
}At least there's Less. Anyone use it, or know of a better system?
One of them is people who completely misuse buzzwords in an attempt to seem more relevant/knowledgeable/important than they really are.
It is not often that I wish I could actively downvote an article on HN, but today I do.
[1] http://plpatterns.com/post/482063133/every-time-you-use-css-...
It is also worth noting that facebook contracted her to help them reduce their out-of-control CSS. I don't remember her exact numbers, but I know she cut down the size down by >50%
However if the naive understanding of objects is that you define a base object, and then extend, or orverride that base object then I think this fits the bill.
I love the grid without overflow:hidden, bring by the "X X X X X..." on a :after. More of a framework, OOCSS supply a philosophy: reuse, reuse and reuse.
The way I understand and I use the Oriented Object concept in CSS, is to provide "graphical" behavior to DOM element: ie: a <div> can extend the shadow behavior with one class and the red border with another. It permit to keep the CSS short, highly maintanable and to make the CMS more flexible, by giving more options to remix a block.
But the risk using this framework is to multiply className on a element, this fact have to be known, not to fall on a trap with double sized html !
The bases of OOCSS: - the template: <div class="page"> is the wrapper you can add the 'liquid' class to make your design fluid
- the grid: line / unit sizeXonY or lastUnit, the sizeXonY give the width of the 'cell', lastUnit permit the last <div> of a line to take the left place.
line contains unit, no margin or padding on unit (Groxx , to keep the percentage true (4 x25% = 100% vs 4x(25% + 10px (ie.margin)) > 100%)
- the block : see http://oocss.org/module.html but to be concise, the mod structure is bullet proof to insert corner, shadow on a block, without CSS3.
- fews plugins (not always useful) to supply solution to main CSS trick.
You can have more info here: http://oocss.org/ or in looking the demo in the git repository.
And a last thing, the resume of Nicole Sullivan (Stubbornella) give her credibility (to me): W3C, Yahoo!, Facebook... She's also the co-creator of http://www.smushit.com/ysmush.it/, the image size burner by Yahoo!
Hope it could help you to go deeper in this framework,
Keep goin' on Nicole !
Instead of this:
<div class="span-12 loud last"></div>
You do something more like this in your SCSS: .mydiv {
@import column(12, true);
@import loud;
}Edit: Scratch that, the download seems to be working now, and it contains some better documentation.
The author uses OO-based css examples all throughout the book, it was my first time reading about it and thought it was pretty cool. You could read through the descriptions on Amazon to get the general idea.
How does this compare to sass? I suppose this also works as a preprocessing step, and 'compiles' to CSS?
Someone wrote a post I agree about this.