2011-03-19 66 views
1

使用XSLT構建選擇產品的列表。 他們顯示在三行。 我想添加一個類到每一行的最右邊(第三個)框來刪除右邊距。 任何想法我可以做到這一點? 對於XSLT來說我真的很陌生。將類添加到每個第三個元素

+2

看到http://stackoverflow.com/questions/3806578/xsl-for-each-add-code-block-every-n-rows – 2011-03-19 15:10:16

+0

所有這些序列分區遵循相同的模式,製作的表N列。示例http://stackoverflow.com/questions/2355952/xslt-rendering-a-node-sequence-as-m-x-n-table。其他:http://www.google.com/search?q=site%3Astackoverflow.com+xslt+list+into+table – 2011-03-19 15:10:38

+0

謝謝斧頭。那正是我想要的。 – 2011-03-19 15:13:45

回答

1

這是我從Umbraco論壇獲得的解決方案。不能讚揚它,但我將其發佈以供將來參考。

<xsl:for-each select="$currentPage/child::* [@isDoc]"> 
<div class="something"> 
    <xsl:if test="position() mod 3 = 0"> 
    <xsl:attribute name="class">something someotherclass</xsl:attribute> 
    </xsl:if> 
    Content of div 
</div> 
</xsl:for-each> 
相關問題