Forum Moderators: not2easy
I am currently accomplishing this with a table, but when I add another link to the list, I have to redo much of the table.
Is there a way to do this with CSS so that all I need to do is insert the new link code in the proper alpha order and the columns will balance themselves out so they are the same length? I don't have php support.
An alternative might be to to do left/right instead on top/down: in that case: yes we can balance the colums by e.g floating the elements (and even go further by e.g adding columns as the page gets wider)
If you do this, a title in the form of the letter etc can easily be added in between as well.
To go for it straightforward: CSS3 will have what it takes.
[w3.org...]
Both mozilla and webkit (ie. FF, safari, chrome etc.) already implement it under vendor specific tags such as:
-moz-column-width
-moz-column-count
-moz-column-gap
-moz-column-rule
-webkit-column-width
-webkit-column-count
-webkit-column-gap
-webkit-column-rule
If you find an alternate solution for browsers not yet on CSS3, you can start using these for the time being.
Now even if you have to balance it manually, it's going to be a *lot* easier if you use simple CSS vs. a nested table or such thing.
Now even if you have to balance it manually, it's going to be a *lot* easier if you use simple CSS vs. a nested table or such thing.
I don't mind balancing manually if it is going to be easier to use CSS than tables. How would I do this - or could you point me to an example or tutorial?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>untitled</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
h1 {
text-align:center;
}
h2 {
clear:left;
color: gray;
padding-top: 20px;
}
p {
width: 15em;
float: left;
}
</style>
</head>
<body>
<h1>index</h1>
<h2>A</h2>
<p>alpha</p>
<p>alternate</p>
<h2>B</h2>
<p>believe</p>
<p>best</p>
<p>beta</p>
<p>betray</p>
<p>better</p>
<p>bullet</p>
<p>bully</p>
</body>
</html>
Only tested in FF3, might not behave all that well in other browsers.
This adds columns based on the available width, if you seek just 2, set the width to 50%.
You can probably consider other elements than a <h2> and a <p> (e.g a <dl> might be far more appropriate)