我正在使用此代码来显示事件。每个事件都是可点击的,但我真的需要一个背景色悬停效果。也许没有 JavaScript 也有可能?
<table class="tableLine">
<tr>
<th>Wann?</th>
<th>Was?</th>
<th>Wer?</th>
<th>Wo?</th>
</tr>
<?php
$all_events = array();
$ten_events = array();
for($i = 0; $events = mysql_fetch_object($events_resource); $i++){
if($i < 9){
$ten_events[] = $events;
}
$all_events[] = $events;
}
$i = 0;
foreach($ten_events as $event){
$row = $i % 2;
echo "<tr onclick=\"window.location.href = '?page=single_event&id=$event->id'\" style=\"cursor: pointer;\">
<td class='row_{$row}'>{$event->de_date}</td></a>
<td class='row_{$row}'>{$event->category}</td>
<td class='row_{$row}'>{$event->who}</td>
<td class='row_{$row}'>{$event->location}</td>
</tr>";
$i++;
}
?>
CSS
这是我的行的 CSS 代码。
.tableLine {
font-family: Verdana,Arial,sans-serif;
font-weight: normal;
font-size: 10px;
width: 614px;
border: 0;
padding: 0;
border-spacing: 0;
text-align: left;
}
.tableLine th {
background-color: #990000;
color: #f3f2ea;
font-weight: bold;
}
.row_0 {
background-color: #424140;
padding: 3px 5px 3px 5px;
color: #f3f2ea;
}
.row_1 {
background-color: #555352;
padding: 3px 5px 3px 5px;
color: #f3f2ea;
}
.tableLine tr:hover {
background: #990000;
}