【发布时间】:2017-11-18 07:33:07
【问题描述】:
我需要将具有冷冻温度(32F,0C)的单元格的背景颜色更改为#bff9ff,但有一些困难。我试图在 <td> 中打印 CSS 类,但似乎它在循环内无法正常工作并同时被打印。
但是,这只是一个问题。我怎样才能识别那些温度低于冻结温度的细胞而不是手动而是使用PHP?
<html>
<head>
<meta charset="UTF-8">
<title>Unit 3 part 2</title>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
tr:hover {
background-color:#bff9ff;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;``
}
.cell {
background-color: #00bfff;
}
</style>
</head>
<body>
<table border="1" cellpadding="3">
<thead>
<th>Fahrenheit</th>
<th>Celsius</th>
</thead>
<?php
$fahrenheit = 50;
while ($fahrenheit >= -50) {
$celsius = ($fahrenheit - 32) * 5 / 9;
print "<tr><td>$fahrenheit</td><td>$celsius</td></tr>";
$fahrenheit -= 5;
$celsius -= 5;
} ?>
</table>
</body>
</html>
【问题讨论】:
标签: php css loops while-loop html-table