相关疑难解决方法(0)

使用XSL在tr类中交替行颜色

我有一个XSL文档,其中插入了可变数量的文章.我需要文章的背景颜色交替 - "奇怪"然后"偶数"

<xsl:for-each select="newsletter/section/article">
    <tr class="odd" style="background-color: #efefef;">
        <td valign="top">
            <xsl:element name="a">
                <xsl:attribute name="href">
                    <xsl:value-of select="link" />
                </xsl:attribute>
                <img align="left" valign="top" width="110" 
                            style="padding: 0 4px 4px 0; border:0;">
                    <xsl:attribute name="alt">
                        <xsl:value-of select="title" />
                    </xsl:attribute>
                    <xsl:attribute name="src">
                        <xsl:value-of select="img" />
                    </xsl:attribute>
                </img>
            </xsl:element>
        </td>
        <td valign="top" style="padding: 4px 4px 18px 0;">
            <strong>
                <xsl:element name="a">
                    <xsl:attribute name="href">
                        <xsl:value-of select="link" />
                    </xsl:attribute>
                    <xsl:value-of select="title"/>
                </xsl:element>
            </strong>
            <br />
            <xsl:value-of select="excerpt"/>
        </td>
    </tr>
</xsl:for-each>
Run Code Online (Sandbox Code Playgroud)

我看过这篇文章:通过XSL交替排行颜色的HTML表格

但我相信我的情况有所不同.我只需要在每次迭代时更改tr类.很抱歉奇怪的格式化,我似乎在浏览Chrome中的代码时遇到了问题.

xml xslt

6
推荐指数
1
解决办法
6877
查看次数

标签 统计

xml ×1

xslt ×1