2015-10-19 69 views
1

我已经从xml格式的互联网存档下载了堆栈交换数据转储。我使用xslt将其转换为html。现在一切工作正常,除了表不自动调整。我已经将其分配为100%,并尝试使用div。任何帮助?为什么我的html表不能自动安装?

<table border="1" width="100%" cellspacing="0"> 
    <tr bgcolor="#9acd32"> 
     <th>Title</th> 
     <th>Body</th> 

    </tr> 
    <!-- for-each processing instruction 
      Looks for each element matching the XPAth expression 
      --> 
    <xsl:for-each select="posts/row"> 

    <tr> 
     <td width="30%"> 
     <!-- value-of processing instruction 
     process the value of the element matching the XPath expression 
     --> 
     <xsl:value-of select="@Title"/> 
     </td> 
     <td width="70%"><xsl:value-of select="@Body" disable-output-escaping="yes"/></td> 

    </tr> 

    </xsl:for-each> 
    </table> 

我试着用外部CSS样式,但它也不起作用。它与xml数据的结构有什么关系?如果是这样,请查看这些数据,这些数据在互联网存档中。

回答

0

您可能需要在父容器上设置宽度。

<body> 
    <div style="width:400px"> 
     <table> 
      content 
     </table> 
    </div> 
</body> 

宽度也可以设置为100%。 小提琴:https://jsfiddle.net/epg2775r/

请注意,使用类似的bgcolor,宽度和CELLSPACING属性已过时,CSS应改为使用。

+0

还是同样的问题 –

+0

@ user309358你能提供你的html代码吗? –

+0

你在上面看到的是html的基本逻辑。我正在使用xslt以htmlesque格式显示xml –

相关问题