2009-04-11 72 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>