PDA

View Full Version : Suggest CSS replacement for table layout


Spudhead
05-29-2003, 03:47 PM
Hey,

The following code displays various "features" paragraphs associated with a product. Each product may have all, some or none of the features - I hope the code is fairly self-explanatory:


<%
if strOpinion<>"" then strOpinion="<span class=""subhead"">Our opinion</span><br>"&strOpinion
if strWSG<>"" then strWSG="<span class=""subhead"">World snowboard guide</span><br>"&strWSG
if strApres<>"" then strApres="<span class=""subhead"">Apr&egrave;s ski</span><br>"&strApres
if strActivities<>"" then strActivities="<span class=""subhead"">Activities</span><br>"&strActivities
if strPriceCheck<>"" then strPriceCheck="<span class=""subhead"">Price check</span><br>"&strPriceCheck
if strTransfers<>"" then strTransfers="<br><br><span class=""subhead"">Transfers</span><br>"&strTransfers
if strSnowSavers<>"" then strSnowSavers="<span class=""subhead"">Snow savers</span><br>"&strSnowSavers
%>
<table cellpadding=10 cellspacing=0 border=0>
<tr>
<td width="50%" class="body" valign="top"><%=strOpinion%></td>
<td width="50%" class="body" valign="top"><%=strWSG%></td>
</tr>
<tr>
<td width="50%" class="body" valign="top"><%=strApres%></td>
<td width="50%" class="body" valign="top"><%=strActivities%></td>
</tr>
<tr>
<td width="50%" class="body" valign="top"><%=strPriceCheck%><%=strTransfers%></td>
<td width="50%" class="body" valign="top"><%=strSnowSavers%></td>
</tr>
</table>


The problem is that, while achieving the desired two-column layout, the code above produces empty table cells - and hence poorly laid out copy - if features aren't there for a particular product.

What I'd like is to adopt a CSS layout that will produce two columns of equal width and fairly equal height, using only the features paragraphs available for the product.

This may - probably will - involve some ASP re-coding as well as any CSS implementation, as the copy is coming out of a database, but I thought I'd stick it in here first; it can be moved later if required.

Thanks for any suggestions....

Saj
05-29-2003, 06:43 PM
I'm not positive that this would work, and with never using ASP myself I'm not sure if this would work, but could you say that if the variable you're printing is blank, then print the string:

&nbsp; (For any mods who read this, is it possible to convert the HTML space entity to regular charcters instead of adding a space?)

That automaticly creates a space for the HTML, and it should clear up any table problems you encounter

jkd
05-29-2003, 08:18 PM
Originally posted by Saj
(For any mods who read this, is it possible to convert the HTML space entity to regular charcters instead of adding a space?)

&amp;amp;nbsp; ;)