Newspaper columns?

I'd like to avoid reinventing the wheel, so if anyone has a good solution for newspaper columns with CSS2, MySQL and PHP, I'd love to hear it. I'm building for my company, so I might be able to pay you for it.

newspaper columns --- an explanation

Look at a newspaper. See how the fcolumns line up across the page. The text flows down one column, then started at the top of the next and flows down. It has to be dynamic. I'm not sure, but I don't think CSS2 supports this. Does anyone know how to do it in PHP?

Newspaper columns?

I could have sworn I saw a similar effect in the CSS2 spec. Apparently not.

The problem you're going to face working this way is lining the bottom of the columns up. You shouldn't really do fixed-height columns, as user agents render text differently (and users can have different default text sizes) - but then variable-length columns won't get the effect you want.

It'd be pretty easy to knock up a PHP script, count the number of words in the string to print out, divide by the number of columns - if you're feeling daring you could do it by the width of each character and get a really accurate spread of text.

Personally I'd consider whether a newspaper format would work on the internet - I personally wouldn't want to scroll down to the bottom of one column and scroll back up to the next - again, it's difficult to cater for all screen sizes, probably here at work (1280x1024) it'd be OK but some people still run 800x600 (640x480? hope not). But that last bit is just my opinion, I know nothing of the context you're going to use this in.

You know you're a geek when you try to shoo a fly away from the monitor with your cursor.

Newspaper columns?

Hi Chewmanfoo,
The real problem is that you don't know the length of each column.
If you can break the content into sections such as paragraphs that are approximately the same height or use php to estimate the size of each small block of content you should be able to get the look your after.

:idea: Why not use php to count characters, then each say 200 characters (just a number) find the next period and wrap that section in span tags.
Place them in an array for a moment, then divide the number in the array by the number of columns you want. The rest should be easy just lay them out into the columns.
You should end up with reasonably similar length columns.

All good responses - funny CSS2 doesn't have this

Thanks everyone! I did notice that in the CSS3 spec, there's support for this http://www.w3.org/TR/css3-multicol/ That's nice. Now, I'm taking bets on how long it will take for this option to appear in my favorite browser (mozilla.) Anyone want to wager?

Newspaper columns?

I'd like to think it would be supported soon, but in reality I know it willl take a long time. Firstly you can count IE out for the next couple of years as no development for future versions will be released without the purchase of an operating system.

hmm...

I sorta just came here outta nowhere, but I saw this hread and thought it was so interesting I needed to reply:)
My suggestion is that you use php the count the words in the article (like mentioned earlier). Use the explode() function to split the article into single words and put it in a array. "count()" (pretty self-explaining) counts the values in the array. Then make some kind of if-loop to find out if you're halfway through the article, and then start a new column. Does this make any sense? Anyway... PM me if you need further help.

Newspaper columns?

I'm new here but hopefully will be able to contribute some of what I've learned in the future.

The best three column "newspaper" layout I've seen is the International Herald Tribune site, which gives you the option to switch between one and three column layouts at the bottom. It works better in some browsers than in others (I know... goes without saying). I keep meaning to tear through their code and look at what's going on, I've just havn't found the time yet.

Newspaper columns?

I know this is an old thread, but it may be helpful for anyone else that Googles for the same thing I did:

php routine to split my text into 2 columns (sometimes I'm soo lazy and can't be bothered writing one myself).
Thanks to eirikra for the psuedo-code.

This will output an HTML table, 2 columns of 200pix wide:
I didn't want the text split exactly in half, because it doesn't look quite right in my application, but you can play with the "halfthewords" variable, of course.