0

This is a follow up to How to distribute People Search Core Results over two columns using XSL,

When I use the suggested code block in that article

    <xsl:for-each select="All_Results/Result">
         <xsl:if test="position() mod 2 = 1">
              <div style="width:50%;float:left;"><xsl:call-template name="SingleResult"/></div>
         </xsl:if>
         <xsl:if test="position() mod 2 = 0">
              <div style="width:50%;float:right;"><xsl:call-template name="SingleResult"/></div>            <div style="clear: both;"></div>
         </xsl:if>
    </xsl:for-each>

I end up with
1
    2
3
    4

Any suggestions on how to get the results
1 | 2
3 | 4

Thank you.

1

The code you posted includes the following after the right column

<div style="clear: both;"></div>

Is this perhaps making your content wrap since you have the widths of your first two divs set to 50%.

0
<div style="width: 100%">    
 <xsl:for-each select="All_Results/Result">
   <div style="width:50%;float:left;"><xsl:call-template name="SingleResult"/></div>
 </xsl:for-each>
<div>

Assuming there is no other styling then this should work fine as it will fill the container div with two at 50% and then wrap to the next line. What you are seeing is what usually happens if you have some padding or margin which means that two divs at 50% are actually more than the 100% outer div.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.