I would recommend designing and debugging your HTML first, and then writing the XSLT to generate the HTML once you know that it works.
Your problem here looks like an HTML problem rather than an XSLT problem.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference