If you're like me and like a quick-summary over a lengthy article, you might like this article: 'Learn CSS Positioning in Ten Steps'[0]. It quickly summarizes all the positionining properties, and how top/left/float/clear etc helps.
nicely explained. one key trick they're missing: position:relative + position:absolute, which I find myself using more than position:absolute alone. With a parent of position:relative, child position:absolute elements are position absolutely within the parent. Nice for centering overlays and things like that.
ah, good point, "Our #callout element is set to position: absolute, and since its parent element, #content is set to relative, the offset properties we’re using on #callout are based off the coordinates created by #content."
would be nice to see it called out as one of the core techniques above though. or I guess I could have just read the whole article before commenting :)
Once you understand all this, you still need to KISS. Going overboard with clever CSS manipulation has two major drawbacks:
1) "Fragile" layouts, where simple changes break the entire UI.
2) Broken javascript - as an eample, jQuery-UI uses the positioning in the DOM to calculate where to display some UI elements. Mixing relative and absolute positioning breaks these functions.
I wanna cry, i had been writing a beautiful comment with examples, explanations, divagations, and when i was done i hit ctrl+R out of habit from developing.
I really wanna cry... Please implement a cookie based autosave for comment forms :'(
Briefing of my hardworked comment that will never be read:
-----------------------------------
I know about the px thing.
Fluid interfaces and traditional box model are wrong because padding and border mess things up
You cant substract % - px, and % in width and height is calculated without taking in account border and padding.
I gave an example (wont rewrite it again)
I gave a few solutions:
* extra markup inside the boxes with % ( ex. div.absolute>div.padding20>content )
Ugly and unsemantic, but usable
* using positioning top/bottom and left/right for defining widths and heights
This only works if you define boths of properties, anyway else if you specify width/height with padding/border it screws you
* use new CSS3 box-sizing property
Not compatible in all browsers, but maybe the best option thinking to future
I also said that a webapp like google calendar would benefit from this things, right now in chrome it gives me 2 scrollbars on the right side, one for the body and another one for the calendar pane.
Uh and heights is crappy because an element only expands to 100% height if parent is 100% height, anyway else it doesnt do shit. This is pain in the ass, redundant and messy between browsers.
Better option is to specify each box coordinates and anchors (and subsequently width and heigth) with position absolute top/left/right/bottom and then define padding without having troubles.
If somebody asks more i will jsfiddle some examples
If you have an iPad, you might want to take a look at cssMachine. It lets you try out the more graphical CSS properties with intuitive controls (rather than just typing code, although you can do that too)
This is probably off-topic. But can any design gurus recommend a beginner CSS and a Photoshop book? Is site-point books any good? Thanks for the help in advance.
For CSS, I've recommended "Learning Web Design" by Jennifer Niederst Robbins to several people. It's a bit out of date now (doesn't cover HTML5 and CSS3) but you shouldn't be learning the latest additions before you have a solid grasp of the basics anyway.
I've been unable to find a good introductory Photoshop book.
Are people still creating custom CSS for layout? I fell in love with the grid css frameworks and haven't looked back. Looking at most of the websites that come through these parts, I'd say they have too...
Whether you're using 960gs or whatever it may be, you still need to be considerate of position and "write css for layout".
If you find yourself always using grid layouts, not just as guides but as the way to lay out everything, then you will soon find yourself caged inside that grid.
This is exactly it. The move away from tables had the side benefit of being able to move away from row and column thinking (there will always be an underlying grid in good design, but breaking it is where a good designer really adds value).
If you don't stick with the grid the framework provides you are just writing custom CSS anyway, at which point you probably wonder why you have another CSS file with lots of code that you are only using 50% of the time and that comes with it's own maintenance issues that you don't need.
I would also argue that from a maintanence point of view, semantically smart class and id names make it much easier to work with compared with a page full of "r3 w50 h10" type attribute properties.
To stick my flag to the mask, I hate CSS "frameworks" with something of a mild passion. CSS is too domain (domain in this sense I guess is a synonym for project) specific and abstract to benefit from a framework, you are much better keeping it lean and tidy and owning every line you write, because CSS is the kind of language where you should justify every line to yourself.
Good points. However I have to say I love frameworks (compass?) that handle all the cross-browser / ie6 stuff for me. If that is not reason enough to use CSS frameworks, I don't know what is.
Same. I've recently been experimenting with several - Less Framework, Less.js, Compass, and Flawless.css. html5boilerplate is also nice for starting templates.
Bypassing those niggling pita xbrowser/ie6 issues with just a 'git clone' is clutch.
[0]: http://www.barelyfitz.com/screencast/html-training/css/posit...