how can I format a TABLE like this?

N

Nobody

Ok, I've got my page laid out pretty much how I want it, but can't figure
out one part...

my "content" area is a fixed width table with 2 columns... COL A = 600px
wide & COL B = 170px wide...

COL A will show the list of available items... this is the part I'm having
trouble with. COL B is irrelevant for this discussion.

I want each item to be about 150px wide (about 25% of the width of 600
pixels for COL A)... So obviously I'll only have a max of 4 items across...

The issue is that sometimes a row will not have 4 items across... sometimes
it will have 3, 2 or 1. If it has 3 across... I still want the items to be
about 150px wide, but be spaced evenly (ie.. each padded to 1/3 the width
without enlarging the 150px item)... 2 items? each item will still be 150px
wide, but be spaced out evenly to 50% of the width.

I can figure out how to do that for 4 items and hardcode the width at 25%
each and it'll all work fine, but how do I adjust for 3, 2, or 1 item rows?

The rows are being built using a repeater control that hits up a stored proc
in the database (datasource).

Thanks!
 
K

Kevin Frey

Well, you have Column Width, and you have Item Width.

What you are really saying is that you want to display a table but the last
row of the table effectively has a "variable" number of evenly-spaced
columns, somewhere between 1 and N (N=4 in your example).

So, here's two suggestions - neither of which will necessarily produce a
satisfactory outcome, but are both worth a try:

1. Make every row a separate table, or make just the last row a separate
table. You can only do this if you are using an explicit table width or
explicit column widths, because otherwise you will probably get /really bad/
misalignment. If you just make the last row a separate table, it might not
actually be that bad, since it's misaligned on purpose.

2. Using spanning columns and choose a number of columns that permits you to
handle all your permutations. For example, if you create the table with 12
physical columns, then when you have 4 items per row you would use
"colspan=3". When you have 3 items per row, you would use "colspan=4". When
you have 2 items per row, you would use "colspan=6", and then "colspan=12"
for the single column.

Kevin
 
N

Nobody

Kevin Frey said:
Well, you have Column Width, and you have Item Width.

What you are really saying is that you want to display a table but the
last row of the table effectively has a "variable" number of evenly-spaced
columns, somewhere between 1 and N (N=4 in your example).

So, here's two suggestions - neither of which will necessarily produce a
satisfactory outcome, but are both worth a try:

1. Make every row a separate table, or make just the last row a separate
table. You can only do this if you are using an explicit table width or
explicit column widths, because otherwise you will probably get /really
bad/ misalignment. If you just make the last row a separate table, it
might not actually be that bad, since it's misaligned on purpose.

2. Using spanning columns and choose a number of columns that permits you
to handle all your permutations. For example, if you create the table with
12 physical columns, then when you have 4 items per row you would use
"colspan=3". When you have 3 items per row, you would use "colspan=4".
When you have 2 items per row, you would use "colspan=6", and then
"colspan=12" for the single column.

Kevin

Hmm... well, I'm using a repeater control, so I really know nothing about
anything. Seems like the repeater control wraps the items automatically. So
I really don't know how many columns or rows I have.

Now that I've had some time to think over this over dinner, although I'm
trying to copy a web site, like you said, the last row will appear
misaligned... so it might just look better (and be easier to do) to make it
all look aligned.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top