Sent by Peter-Paul Koch on 3 March 2005 13:01
> I am trying to create a two-column layout in HTML generated via JSP. The
> left column is an image, and the right is text describing the image. This
> seems pretty straightforward, except for one catch - I don't know the width
> of the image, and all of the 2-column layouts I've seen require some
> knowledge of at least one column's width.
>
> Technically, I *do* know the width and could use JSP to insert the value
> into the properties, with an embedded stylesheet:
>
> .leftColumn
> {
> width: <%= imageWidth%>;
> }
>
> However, I'd like to separate my data and my presentation (that's what CSS
> is all about, right?). So I'd like to have the stylesheet in a separate
> file, and use a link tag to include it. That way, if I decide to change my
> presentation or provide my users with alternate views, I can do so. But, of
> course, a CSS file can't include JSP markup.
>
> I suppose I could have my stylesheets generated via JSP as well, but that
> seems a bit excessive.
>
> Does anyone have ideas for a two-column layout that makes no assumptions
> about column widths?
Use a table. The left column will stretch up as much as necessary, and
the right one will shrink appropriately.
If you don't want to use tables you've got a problem. You have to
define the widths of both columns somewhere, or the float-based
positioning won't work.
If it were my site I'd go for the JSP-generated CSS bit in the HTML
page. True, it's not perfect separation of structure and presentation,
but in your case every individual page needs special instructions
anyway, since all the image are (could be) of different sizes.
As far as I can see this problem is unsolvable with just one general
style sheet, unless you're willing to stretch all left columns to the
width of the widest image.
(Of course I may be wrong; in that case please tell me how you'd do it)
-------------------------------------------------------------------
ppk, freelance web developer
Bug Report: Report bugs yourself, or comment on previously
reported ones.
http://www.quirksmode.org/bugreports/
------------------------------------------------------------------
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/