Learn CSS Positioning
barelyfitz.com
barelyfitz.com
But if you are building a quick app or prototype, I've found frameworks like blueprint (http://www.blueprintcss.org/) to be quite helpful.
CSS frameworks are different from other programming frameworks because it overwrites defaults. It is equivalent to something like overriding printf in c to do add an extra character at the beginning. Its just ridiculous.
It's not like it is really that complicated to make it work from there... If you think it is, learn CSS properly (i.e. stop cutting corners!).
http://dowebsitesneedtolookexactlythesameineverybrowser.com/
Honestly, in my experience:
- The time you invest in learning the ropes of that framework would be better invested in properly learning CSS. I wouldn't say this of any framework in any language, but CSS is easy and, contrarily to what I constantly hear, it isn't that hard to master.
- Once you know CSS well, it's much faster to convert a PSD by hand than trying to make it work with your framework. The more detailed the actual design, the more this applies.
- The only pseudo-framework that actually boosts styling speed is leveraging a well-maintained css reset stylesheet.
Keep in mind that this is coming from somebody that knows CSS well... I understand why a framework sounds appealing, especially since we have a lot of them on the development side, but in the case of CSS, it is total overkill.
The problem with other peoples frameworks is, well... they're other peoples frameworks. Develop your own and you'll love it. Such frameworks allow you to factor your CSS and eliminate repetition and patterns you use often.
Do you have any advice for dealing with this? I feel there ought to be some way of semi-automatically "refactoring" style sheets, or keeping them compact and neat to begin with, but I haven't yet found it.
The biggest difference is probably the IE 5 box model (also called "traditional box model" or "border box"), which doesn't comply with the standard CSS box model. In the IE 5 box model, the size of boxes includes their borders and padding, while in the W3C box model, the size of boxes includes only the content of the boxes (the IE 5 version actually makes more sense, but it's not what's in the standard). In later versions of IE, the standard box model is used, but only if you're in standards mode; the IE 5 model is used in quirks mode. Nowadays, almost all browsers support a CSS3 property, box-sizing that can control which box model to use, so you can actually enable the traditional box model in a standard way (though it's prefixed -moz-box-sizing or -webkit-box-sizing in Gecko and Webkit, as that's the preferred way to implement standards that aren't yet finalized)
For more detail on the differences between quirks and standards mode, see:
http://en.wikipedia.org/wiki/Quirks_mode
and
Of course, with only 9 effective steps of a single demonstration, it's rather lacking in completeness. But that's not its point, and I love all the links in this thread. Loads of good stuff :)
overflow: hidden
to the containing element. In most cases this will cause it to extend and prevent the inner elements from bleeding out. In some edge cases it will cause them to be hidden, though.let me put it in simple terms for people:
you probably don't need to use `clear: both`. almost all of the time, you can use `overflow: hidden` on the parent element instead of `clear: both`.
(the exception of course is when you've got elements with negative margins that would actually be hidden with `overflow: hidden`)
edit: relevant link - http://www.quirksmode.org/css/clearing.html
Right now, my div structure looks like this:
<body>
<header />
<div-hackw>
<div-hack1>
<div-hack2> <article /> </div-hack2>
<nav /> -- written after, displayed on the left
<div-hackw>
<footer />
<body>
http://www.loup-vaillant.fr/css/style.cssinspired from http://matthewjamestaylor.com/blog/ultimate-2-column-left-me... (down right now).
Header, footer, nav, and article are okay (they eventually will be actual html5 tags). Hakcw, hack1 and hack2, however, are ugly. Does anyone know of a way to ditch them ?
I finally found the solution (below), inspired from http://www.positioniseverything.net/articles/onetruelayout/a...
This layout is source ordered (header article nav aside footer), liquid, and the side columns have a fixed width. You can easily do the same thing with 2 columns only. The only drawback left is the fact that I can't force the columns to share the same height. As far as compatibility is concerned, I think an html 4.1 version will work on any relevant browser. So I think I found my ultimate layout. At last.
<!doctytpe html>
<html>
<head><link rel="stylesheet" href="test.css" /></head>
<body>
<header> header header header header header </header>
<article>
article article article article article
article article article article article
article article article article article
</article>
<nav> nav nav nav nav nav nav </nav>
<aside> aside aside aside aside aside </aside>
<footer> footer footer footer footer footer </footer>
</body>
</html>
/* html5 reset */
article, nav, aside, header, footer { display:block; padding:1em; }
/* colors */
html { background-color:#fff; }
body { background-color:#ddd; }
header, footer { background-color:#aaa; }
nav, aside { background-color:#8aa; }
article { background-color:#a8a; }
/* layout */
body { margin:auto; padding:2em; width:35%; }
article { float:left; margin-left:5em; margin-right:5em; }
nav { float:left; width: 3em; margin-left:-100%; }
aside { float:left; width: 3em; margin-left:-5em;}
footer { clear:both; }This looks like the best example I have so far to pass along to people asking me about css, which happens quite often.
That aside CSS is messy and complicated, lots of programmers dont understand the basics, and even experienced developers can easily miss a few very useful tips.
One of the most helpful things I ever did with respect to CSS was read the apress book on html/css patterns (just ignore the parts that use javascript).
http://books.google.com/books?id=xq9IOomk1tUC
(I never realized that standard CSS actually operates with 6 box models!)
Sure you might know CSS inside out, but I'd be willing to bet some people here could learn something useful out of it. The rest of us that already are familiar with it get a quick refresher in under 5 minutes.
Positioning and the box model are at the core of understanding CSS layouts. Sure it's not the next cool thing and it certainly isn't advanced, but I'd much rather browse a Web where people understand layouts properly, than one filled with a lot of the trendy, over-complicated crap that fails at the basics.
We have to be careful with that basic = not challenging = not geek-worthy attitude. A beginner reading HN comments will most likely emulate it and miss out on the important stuff.
If the reader does know CSS, then they're probably asked "can you make this for me?" by everyone and their extended family, and this is concise and has immediate, clear examples to make it newbie-friendly. I wouldn't dare throw a big CSS book at a non-programmer new to CSS.