我正在尝试显示表格的背景图像,但不适用于整个表格。这是代码:
echo"
<font color='white'>
<table width=620 height=600 border='1' style='background-image:url(good.jpg); background-repeat:no-repeat;' >
<col width=40%>
<col width=60%>
<tr bgcolor='#0B0B61' >
<th > Results for <strong>Tracking Number:</strong> </th>
<th> ". $tid . "</th>
</tr>
<tr bgcolor='#0B0B61' >
<td><strong> Status:</strong> </td>
<td> ". $status . "</td>
</tr>
</table>
如果我将其设置为表行或td,它会起作用。
答案 0 :(得分:0)
您为每行设置背景颜色,该颜色将覆盖表格背景。
我必须说您的代码看起来像您15年前编写的代码。
您应该使用class
而非内联样式,例如bgcolor
,<strong>
,width
,border
例如:
.your-table {
color: white;
width: 620px;
height: 600px;
border: 1px solid black;
background-image: url('https://gallery-wallpaper.com/wp-content/uploads/2018/02/beach-scene-wallpaper-for-desktop-desktop-wallpaper-beach-scenes.jpg');
background-repeat: no-repeat;
}
.first-col{
width: 40%;
}
.second-col{
width: 60%;
}
.tracking-number, .status{
font-weight: bold;
}
td{
padding-left: 15px;
}
<table class='your-table'>
<col class='first-col'>
<col class='second-col'>
<tr>
<th>Results for <span="tracking-number">Tracking Number:</span> </th>
<th>". $tid . "</th>
</tr>
<tr>
<td class='status'>Status:</td>
<td>". $status . "</td>
</tr>
</table>
答案 1 :(得分:0)
.table-bg {
width: 300px;
height: 300px;
border: 1px solid blue;
background-image: url("https://cdn.sstatic.net/Img/unified/sprites.svg?v=e5e58ae7df45");
background-repeat: no-repeat;
}
<table class='table-bg'>
<col width=100%>
<tr>
<td><strong> Status:</strong> </td>
<td> ". $status . "</td>
</tr>
</table>