Murray's Blog

CSS pain

I've been trying to learn CSS properly over the last few weeks, but I have come to the conclusion that it just can't do the simple things that web designers should want it to do. In particular it can't seem to be used for pages
whose elements resize and rearrange themselves automatically depending on the size of the text inside them. There are various problems that you meet when you try different ways to do this, but they all seem to lead to the same conclusion. I think that's why so many sites seem to have hard-coded fixed widths, which makes them useless on small devices, and marooned on big screens. And I think it's why almost all sites seem to at least hard-code the width of their sidebars (though you can do it in ems instead of pixels, which is not quite so bad).

For instance, in Problem A, the right-hand box is sometimes at the right-hand, and sometimes below, depending on the width of the window. It should be obvious where it should be and how wide it should be. On www.murrayc.com and others, this is fixed by hard-coded the size of the left-hand box, so that the right-hand box does not have to be floating, because it's floating that acts in this awkward way.

In Problem B I want the 2 inner boxes to be adjacent to each other inside the outer box. In the example, that kind of works, but the outer box has an obviously stupid height. The height of the outerbox is correct if I set it to "clear:left", but then the boxes inside will ignore their height percentages, so they will not be adjacent. You can partially fix that by hard-coding the widths instead of using percentages. Update: Andrew Taumoefolau showed me that you can fix this problem by adding a third, empty, inner div, with "clear: both;". That seems hacky, because it must be in the HTML rather than the CSS, but it works. Thanks Andrew.

Maybe these are browser bugs, but I doubt it. I fear that CSS just isn't that great because it wasn't properly put through the use-cases. Naturally, I'd like to be told where I'm going wrong.

Munich Blogs

I must try to hack planet so that it can get only certain topics/categories, so that people don't have to read this boring crap on munichblogs.com

Exit mobile version