Basics of CSS columns (in plain English):
- Create a sufficient number of columns.
- Make each column a set height and width.
- Put ALL the text in each column.
- Move the text of each column upward to hide what was shown in the last column.
Technical Explanation:
- Create a div tag for each column, all with the same style class.
- Nest a p tag with the full text inside, each with a unique style class.
- Set the div height and width in the stylesheet.
- Set the div overflow to hidden.
- Set each subsequent p margin-top to the cumulative height of all previous columns, but negative.
This effectively hides the previous columns' text in a hidden negative top-margin. The advantage of this approach is that if default font sizes on different browsers change the intended size of your text, it will still show/hide the appropriate amount of text in each column.
This can be accomplished more elegantly by using PHP or JavaScript, and referencing your body text with a variable placed inside each p tag.
To see a demo, go to www.thomasvirginart.com/columns.html. (special thanks to lipsum.com for the text!)
Enjoy!
~Tom
No comments:
Post a Comment