2017-08-16 112 views
0

下面是代码提供。目前,由于span标签,它突出了文字。但我希望它改变该表值的背景颜色,而不是突出显示文本。我会怎么做呢?更改表背景

<c:choose> 
 
    <c:when test="${manifest.manifestRtnedDate == null}"> 
 
    <td class="backgroundHighLight"> 
 
     <c:if test="${manifest.daysOpened >35 && manifest.daysOpened < 45 }"> 
 
     <span style="background-color: #FFFF00"><c:out value="${manifest.daysOpened }"/></span> 
 
     </c:if> 
 

 
     <c:if test="${manifest.daysOpened > 45 }"> 
 
     <span style="background-color: #FF4747"><c:out value="${manifest.daysOpened }"/></span> 
 
     </c:if> 
 
    </td> 
 
    </c:when> 
 
    <c:otherwise> 
 
    <td> 
 
     <c:out value="${ manifest.manifestRtnedDate}" /> 
 
    </td> 
 
    </c:otherwise> 
 
</c:choose>

回答

0

你在正确的轨道上,这里有两种选择。您可以:

  1. 保持你的逻辑,是,并尝试添加display: block;您span元素的风格。这应该使他们填充<td>元素。或...

  2. td元素本身移动到c:if块中,并设置其背景而不是span(请参阅下面的示例)。

<c:choose> 
 

 
    <c:when test="${manifest.manifestRtnedDate == null}"> 
 

 
    <c:if test="${manifest.daysOpened >35 && manifest.daysOpened < 45 }"> 
 
     <td class="backgroundHighLight" style="background-color: #FFFF00"> 
 
     <span><c:out value="${manifest.daysOpened }"/></span> 
 
     </td> 
 
    </c:if> 
 

 
    <c:if test="${manifest.daysOpened > 45 }"> 
 
     <td class="backgroundHighLight" style="background-color: #FF4747"> 
 
     <span><c:out value="${manifest.daysOpened }"/></span> 
 
     </td> 
 
    </c:if> 
 

 
    </c:when> 
 

 
    <c:otherwise> 
 
    <td> 
 
     <c:out value="${ manifest.manifestRtnedDate}" /> 
 

 
    </td> 
 
    </c:otherwise> 
 
</c:choose>

+0

感谢您的快速回复。这解决了它。 – turtlesallday