我有一个像这样的表格单元格:
<td>
@if ($user->status == 1)Present
@elseif ($user->status_detail != null) Absent(see Details)
@else Absent
@endif
</td>
所以我的问题是,我不想只给表格单元格“现在”我想给它一个颜色。你们对这个问题有什么建议吗?
答案 0 :(得分:3)
您需要在元素中添加此内容,如以下示例所示
<td class="
@if ($user->status == 1)
present
@else
absent
@endif
">
@if ($user->status == 1)Present
@elseif ($user->status_detail != null) Absent(see Details)
@else Absent
@endif
</td>
然后在CSS中你可以根据需要定义样式:
.present {background:#0f0;}
.absent {background:#f00;}
答案 1 :(得分:0)
在文字周围添加标签&#34;出现&#34;。然后给跨度使用CSS给出一个类来给出跨度的背景颜色。
<td>
@if ($user->status == 1)<span class="present">Present</span>
@elseif ($user->status_detail != null) Absent(see Details)
@else <span class="absent">Absent</span>
@endif
</td>
在CSS中
.present{ background:#ff0;display:block; width:100%;}
.absent{ background:#f00;display:block; width:100%;}
答案 2 :(得分:0)
@if ($user->status == 1)
$status = Present;
$color = "green";
@elseif ($user->status_detail != null)
$status = Absent(see Details);
$color = "red"
@else
$status = Absent(see Details);
$color = "red";
@endif
<td style="background-color:{{$color}}">{{$status}}</td>
答案 3 :(得分:-1)
<td class="status">
@if ($user->status == 1)Present
@elseif ($user->status_detail != null) Absent(see Details)
@else Absent
@endif
</td>
CSS
.status {background:#fff;}
或者在缺席或在场时应该有所不同吗?