gpt4 book ai didi

html - 保留元素内的空间并删除元素之间的空格(空行)XSLT、CSS

转载 作者:太空宇宙 更新时间:2023-11-03 18:03:52 27 4
gpt4 key购买 nike

一直在尝试使用输出 html 方法转换 xml 文档,以便使用 xsl 样式表(使用 CSS)在浏览器中显示。想显示以下代码

 <paragraph> 
<content>Source A</content>
</paragraph>
<paragraph>
<content>Color Yellow </content>
</paragraph>

作为

Source                   A  
Color                       Yellow 

with space preserved between "Source" and "A", and space preserved between "Color" and "Yellow", but space (blank rows) removed between the rows. I am able to do either, for example wrapping the content nodes with pre nodes preserves space within the elements, and using

  <p>
{ margin:0}

删除行之间的空格。但是,我无法同时完成这两项工作。尝试了各种选项,如 whitespace:pre、xsl:preserve-space 和许多其他组合,但均未成功。谢谢

最佳答案

XSLT 保留空白。 HTML 只是默认情况下不显示它。

使用这个 CSS 指令:

p { 
white-space: pre;
}

和像这样的 XSLT:

<xsl:template match="paragraph">
<p><xsl:value-of select="content" /></p>
</xsl:template>

关于html - 保留元素内的空间并删除元素之间的空格(空行)XSLT、CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24999121/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com