Hmmm... You seem to be making this much more complex than it needs to be.
Why not do something like this:
XSL: <xsl:template match="fotografie"> <xsl:apply-templates/> </xsl:template>
<xsl:template match="foto">
<div class="thumbnail" onclick="expandImage()">
<div class="imageContainer"> <img src="[EMAIL PROTECTED]" class="img"/>
</div>
<div class="description">
<xsl:apply-templates select="."/>
</div>
</div>
</xsl:template>
CSS: .thumbnail { display:inline; margin:10px; }
.imageContainer { padding:3px; border:1px solid blue; }
.img { width:20px; height:20px; }
.description { font-size:80%; padding:10px; }
With this you can have you gallery have the columns fit the width of the (resized) window and they will wrap when necessary. Perhaps I am missing why you need the complexity?
Because I need a 'matrix' of thumbnails, with the number of columns in this matrix/table to be customizable. Your stylesheet generates only one column all the time.
Stefano.