2009-04-11 69 views
0

我的关于在网页上正确布置文本的其他问题。我想编写RSS代码,然后使用XSL将RSS格式化为HTML 我的问题:与XSL中的文字布局和边距有关的问题

为什么ITEM DESCRIPTION的文本不在网页的页边空白处?如何强制这段文字保持在边缘内? Run out of margin http://i40.photobucket.com/albums/e236/ngquochung86/somemargin.jpg

我的XML代码:

<channel> 
....... 
    <description> 
    CHANNEL DESCRIPTION: Website of New York Times 
    </description> 
    <item> 
    <title> 
     ITEM TITLE:YouTube and Universal to Create a Hub for Music 
    </title> 
    <link> 
    <a href="http://www.nytimes.com/2009/04/10/technology/internet/10google.html?ref=technology"/> 
    </link> 
    <description> 
    CHANNEL DESCRIPTION: The agreement is an effort by YouTube, which is owned by Google, to put more professionally produced content in front of its huge audience, and in turn, earn more money from advertising. 
    </description> 
    </item> 

我的XSL代码:

<span class="channelDescription"> <xsl:value-of select="channel/description"/></span> 
      <xsl:for-each select="channel/item"> 
       <span class="itemTitle"><xsl:value-of select="title"/></span> 
       <span class="itemLink"><xsl:value-of select="link"/></span> 
       <span class="itemDescription"><xsl:value-of select="description"/></span> 
      </xsl:for-each> 

你可以帮我吗?谢谢

+0

这是一个真正的CSS问题。它很容易看到简单的HTML生成,并将XSL排除在等式之外。但是,您不会向我们展示用于格式化HTML的CSS。 – AnthonyWJones 2009-04-11 14:51:34

回答

1

像AnthonyW琼斯说,这似乎是一个CSS/HTML问题。一旦您使用XSLT将RSS提要转换为HTML,它将被简单地视为(并因此呈现)为标准HTML文档。

在这一点上我最好的猜测是,你需要把一个容器周围的说明(或整个文件)(块级元素,如< DIV>),并指定一个宽度为它是内使用CSS显示器的尺寸。

所以这样的事情应该工作:

<style type="text/css"> 
#container { 
    width: 90%; 
} 
</style> 
<div id="container"> 
    // Your XSL code 
</div>