Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Complete CSS Reference (developer.mozilla.org)
108 points by cwan on Nov 27, 2011 | hide | past | favorite | 6 comments


I really hadn't studied the newer pseudo-classes in css3. It seems like you can get away with a lot less class attributes in HTML which might have been added by a server side language or JS. The :nth-child for selecting even/odd rows of tables comes to mind.

That being said, CSS has always been kind of a black art to me. Floating, em vs percents vs pixels, rules regarding inline vs block elements, the box model with borders, padding and margin... These are all things I had to read up on and experiment with to figure out how they worked. I've spent quite a while trying to read up on all of these things to figure it all out. Contrast this with learning layouts in Java Swing, QT, GTK+ in about 1 days time each. I realize I am comparing a GUI toolkit with the web but... something seems broken here. I'm not sure if it is lack of clear documentation and tutorials, inconstant implementations in older browsers or a failing of the language itself. Maybe its a combination of all of those.


CSS has its own quirks, couple that with browser's own quirks; and it might get hard.

However, here are a few pointers for people who are new to CSS, struggling to get CSS positioning:

http://www.alistapart.com/authors/s/nstokes

Another very important issue is that of "containing floats", http://complexspiral.com/publications/containing-floats/ , th that the height of a container is not expanded to fill its contents is logical from a publisher pov.

Where does one start the next paragraph if a paragraph has a long image on the right? It doesn't start when the image ends, the next paragraph starts when the text in the previous paragraph ends.

Still, though, CSS positioning is hard, and that's why people are using grid frameworks, like 960.gs.

One other major issue is CSS is that all browsers have an internal stylesheet, and those sheets are slightly different, hence people make use of CSS resets or normalizers that default properties to common values.

As a sidenote: To see how one can use CSS to build quality documents, look at PrinceXML: http://www.princexml.com/samples/


I feel exactly the same way. I had the experience of working with a designer on two projects, both of which he gave me pixel-perfect mockups for. One project was an iOS project, the other a web project. Getting the pixels to match up for the iOS project was fairly easy, just a matter of getting the right values for text shadow opacity, setting up stretched images, etc. The web project (which only had to run on newer WebKit browsers) was much harder. I was able to get a first draft very quickly, but getting every last pixel to match a mockup was a painful process to say the least. My takeaway was this: CSS is great for quickly developing styles, but when you need everything exactly perfect, it's a pain in the ass.


I've had to do that once or twice before, and I don't aim for pixel perfect rendering, since it's a sisyphean task. Instead I go for almost pixel perfect.

Pixel perfect on a web browser doesn't make a lot of sense since people could resize their browser, increase/decrease font size, etc.


http://instacss.com is a nice quick-search interface for it.


For some obscure reason word-break is missing (couldn't find it with instacss, can't find it now either).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: