css - XSL 选择样式文本和 td
问题描述
我正在使用 XSLT 选择来设置单元格内容的样式。出于某种原因,它同时设置了文本和 td 的样式。如果我然后尝试<td>
用 CSS 重新着色它只会让它完全消失。
<td>
<xsl:attribute name="style">
<xsl:choose>
<xsl:when test="@status = 'OPEN'">
<xsl:text>color: limegreen;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>color: red;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="@status" />
</td>
我只想让它着色value-of select
,而不是单元格边框。
解决方案
使用上面的代码,您可以为整个<td>
.
如果您只想设置文本样式,请将其应用于<span>
(或其他),如下所示:
<td>
<span>
<xsl:attribute name="style">
<xsl:choose>
<xsl:when test="@status = 'OPEN'">
<xsl:text>color: limegreen;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>color: red;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="@status" />
</span>
</td>
这应该只着色文本而不是边框。
推荐阅读
- python - 当在 Tkinter 中没有输入而取消选择输入字段时,使占位符重新出现
- angular - Angular2 StrategyPattern 注入服务
- java - 当我尝试将图像添加到窗格时,图像不可见
- webassembly - 内存访问越界——但为什么呢?
- javascript - 我的图标没有显示并且我的响应式菜单没有显示
- c++ - 将 mqtt_cpp 库添加到 cmake 项目
- java - 如何在不知道列的情况下将“io.vertx.mutiny.sqlclient.Rowset”转换为地图列表?
- java - 部署到 jar 后获取 java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
- reactjs - 在 React 中访问浏览器扩展
- python - 为什么代理服务器无法收到服务器的响应