I
I
Ivan Kalmykov2016-06-02 11:48:56
XSL & XSLT
Ivan Kalmykov, 2016-06-02 11:48:56

How to stagger div in xslt?

There is a task to deduce elements in a checkerboard pattern.
27736deeb1654979a2dcc177dcdbdb17.png
I can't reproduce it in xslt.
So far I've only come up with this:

<xsl:choose>
        <xsl:when test="position() mod 1 != 0 and position() mod 4 != 0">
            <div class="pego-columns pego-columns3 fl single-service-image">
                <xsl:if test="image_small != ''">
                    <img alt="{name}" src="{dir}{image_small}" class="attachment-full size-full" />
                </xsl:if>
            </div>
            <div class="pego-columns pego-columns3 fl single-service">
            <h1 class="service-title"><xsl:value-of disable-output-escaping="yes" select=" substring-before(name,' ')"/><span><xsl:value-of disable-output-escaping="yes" select=" substring-after(name,' ')"/></span></h1>
                <p class="service-excerpt"><xsl:value-of select="description" disable-output-escaping="yes" /></p>
            </div>
        </xsl:when>
        <xsl:otherwise> 
            <div class="pego-columns pego-columns3 fl single-service">
            <h1 class="service-title"><xsl:value-of disable-output-escaping="yes" select=" substring-before(name,' ')"/><span><xsl:value-of disable-output-escaping="yes" select=" substring-after(name,' ')"/></span></h1>
                <p class="service-excerpt"><xsl:value-of select="description" disable-output-escaping="yes" /></p>
            </div>
            <div class="pego-columns pego-columns3 fl single-service-image">
                <xsl:if test="image_small != ''">
                    <img alt="{name}" src="{dir}{image_small}" class="attachment-full size-full" />
                </xsl:if>
            </div>
        </xsl:otherwise>
    </xsl:choose>

turns out 1116d611e9f649d8b427f835f10f995c.png. And I don’t understand how to force all the elements to be arranged in a checkerboard pattern. Broke my whole head. Help comrades. Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question