2017-08-16 96 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