I am building an Interests page and have come up with 11 Categories, and under each Category there are between 1 and 5 choices.
To display all of this on one page, I was thinking of having two columns with the first one having the first 5 Categories/Lists, and the second column having the remaining 6 Categories/Lists.
My clients website uses HTML4 and is not responsive, so i don’t need anything overly fancy, so long as it looks nice on your standard PC/Browser.
I have heard that HTML Tables are bad, so how should I approach this?
The only thing I can think of is creating two DIVs and somehow making then appear side-by-sdie on one row.
Oh, I should also mention that the # of Categories and the # of List Items could change at any time since this is all coming from the back-end database, and therefore is dynamic!
Thanks for the sample code. It looks similar to mine, but my only concern is that you are taking a grid approach.
I guess I was thinking more or two columns where you could have multiple “cells” (e.g. Categories) that would just keep expanding downward as you added more.
Actually, what would be the coolest is if as you added new “cells” they pushed the next “cells” down in the first column, and when things got to the bottom of the parent container, then things wrapped around to the top of the second column like a newspaper works. (But that is probably asking too much for the web!)
That’s actually even easier, just take out that last row and put the lists immediately underneath each other: http://jsfiddle.net/s7vfhpcn/1/
The columns just divide the page into two, well, columns. They can extend downward as far as you’d like. The rows are there to ensure that the next set of content starts flush with whatever is tallest.
Making them wrap like that is significantly trickier (I don’t think it’s possible with just HTML/CSS)
If I have 11 Categories, maybe I could have my PHP figure the (near) half-way point, and then display the first half (e.g. 5) in Column-A, and the remaining in Column-B?
The columns have percentage widths that total 100%. You will need to apply the margin to the contents of the .column containers. (If I understand the question.)
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>containers + margins</title>
<!--
http://www.sitepoint.com/community/t/side-by-side-lists/116219/10
Mar 22, 5:06 PM
mikey_w
-->
<style type="text/css">
.row {clear:both}
.column {
width: 50%;
float: left;
outline:1px solid blue; /* TEST Outline. To Be Deleted. */
}
h2,ul {
margin-right:5%; /* your choice of unit of measure */
outline:1px solid magenta; /* TEST Outline. To Be Deleted. */
}
</style>
</head>
<body>
<div class="row">
<div class="column">
<h2>Sports</h2>
<ul>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
</ul>
<h2>Sports</h2>
<ul>
<li>Something</li>
<li>Something</li>
</ul>
<h2>Sports</h2>
<ul>
<li>Something</li>
<li>Something</li>
</ul>
</div>
<div class="column">
<h2>Indoors</h2>
<ul>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
</ul>
<h2>Indoors</h2>
<ul>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
</ul>
</div>
</div>
</body>
</html>
I see where I messed up in that I was adding a right margin to each column, when all I had to do was add a right margin to my H2 and UL.
But hypothetically, let’s say my column containers had tons and tons of objects in them to where it would be impractical to add a right margin to everything.
In that case, how would I add a 50px right margin and know how to adjust the percentage so that things always fit?
I see you used a percentage unit on the margin in your code, but is that legitimate?
If you can’t do that, then I don’t know how you figure out 100% - (2 * 50px) = ___% column-width.
Then you put a wrapper around the content containers and apply the margin to the wrapper.
I used a percentage and indicated that you can use any unit of measure that suits your design. It will not impinge on the width of the .columns. (am I following you?)
EDIT:
Another thought… if your tons of objects are ultimately within block containers, you could possibly add a common classname to each container and assign the margin to that classname; thus avoiding the extra wrapper.
<style type="text/css">
.row {clear:both}
.column {
width: 50%;
float: left;
outline:1px solid blue; /* TEST Outline. To Be Deleted. */
}
.mymargin {
margin-right:50px; /* your choice of unit of measure */
outline:1px solid magenta; /* TEST Outline. To Be Deleted. */
}
</style>