首页 > 解决方案 > FO 列表块更改样式

问题描述

我正在使用 XSL FO 列表块来显示项目符号。是否可以更改 list-style-type 以显示正方形(或其他形状)?在 HTML 中,它是<ul style="list-style-type:square;">

代码:

<fo:list-block>
<fo:list-item>
 <fo:list-item-label>
   <fo:block>*</fo:block>
 </fo:list-item-label>
 <fo:list-item-body>
   <fo:block>Volvo</fo:block>
 </fo:list-item-body>
</fo:list-item>
<fo:list-item>
 <fo:list-item-label>
   <fo:block>*</fo:block>
 </fo:list-item-label>
 <fo:list-item-body>
   <fo:block>Saab</fo:block>
 </fo:list-item-body>
</fo:list-item>
</fo:list-block>

标签: htmlxsltxsl-foapache-fop

解决方案


把你想要的字符放在*

<fo:list-item-label>
  <fo:block color="blue" font-weight="bold" font-size="1.3em">✪&lt;/fo:block>
 </fo:list-item-label>

与 相比,这看起来需要做很多工作<ul style="list-style-type:square;">,但是:

  • 您通常只需要这样做一次,因为您正在使用 XSLT 生成 XSL-FO
  • 您可以完全控制列表项标签的内容、大小、重量、颜色、对齐方式(参见relative-alignhttps ://www.w3.org/TR/xsl11/#relative-align )和位置(以及,如上所述,您通常只需要设置一次)
  • 如果您愿意,您可以更改,例如,通过position()在 XSLT 中使用每个列表项的项目符号颜色
  • 当您查看编号列表项时,您会发现这xsl:number使得生成分层编号以在列表项标签中使用变得很容易。(如果您使用的是 AH Formatter,您还可以使用一组预定义的计数器样式:https ://www.antennahouse.com/product/ahf66/ahf-ext.html#axf.counter-style 。)

推荐阅读