具有颜色范围的线条
Lines with color ranges
我的代码用一些数据构建了一个 table,我想使用 CSS 和 PHP.
按颜色区分线条
我的代码:
foreach ($resultSql as $line) {
$_atribute = $this->recoverAtribute($line'attribute_id']);
$_optionText = $this->recoverOptionid($_atribute, $line['option_id']);
$desc=$line['ds_cont'] ;
$order = array("\n");
$replace = '<br />';
$newstr = str_replace($order, $replace, $desc);
if($line['ds_cont']='dest'){
echo $line['ds_cont']='';
}
if (isset($line['ds_cont']) && $line['ds_conteudo'] != '') {
echo '<tr >
<td class="table-carac-title" style="padding-left: 45px !important;padding-right: 45px !important; "> ' . ucwords( strtolower($_optionText)) . '</td>
<td class="table-carac-desc" style="padding-left: 45px !important;padding-right: 45px !important;"> ' . $newstr. '</td>
</tr>';
} else {
echo '<tr >
<td class="table-carac-title" style="padding-left: 45px !important;padding-right: 45px !important;">' . $_atribute->getFrontend_label() . '</td>
<td class="table-carac-desc" style="padding-left: 45px !important;padding-right: 45px !important;"> ' . $_optionText . '</td>
</tr>';
}
$count = $count + 1;
}
您可以在偶数行和奇数行上设置特定的css:
tr:nth-child(even) {background: #CCC}
tr:nth-child(odd) {background: #FFF}
您需要创建一个奇数和偶数的逻辑并添加到您的示例的 class 中:
$classtest = '';
if ($count % 2 == 0) {
$classtest = 'pair';
} else {
$classtest = 'odd';
}
在你的 TR 标签中:
'<tr class="active ' . $classtest . '">
您可以使用 $count 变量来设置每行要更改的颜色类型或其他值,如下所示:
if ( ($count % 2) == 0 )
$myColor = "color:black";
else
$myColor = "color:white";
# In you HTML element
echo sprintf('<tr style="%s"> ... something ... </tr>', $myColor);
我的代码用一些数据构建了一个 table,我想使用 CSS 和 PHP.
按颜色区分线条我的代码:
foreach ($resultSql as $line) {
$_atribute = $this->recoverAtribute($line'attribute_id']);
$_optionText = $this->recoverOptionid($_atribute, $line['option_id']);
$desc=$line['ds_cont'] ;
$order = array("\n");
$replace = '<br />';
$newstr = str_replace($order, $replace, $desc);
if($line['ds_cont']='dest'){
echo $line['ds_cont']='';
}
if (isset($line['ds_cont']) && $line['ds_conteudo'] != '') {
echo '<tr >
<td class="table-carac-title" style="padding-left: 45px !important;padding-right: 45px !important; "> ' . ucwords( strtolower($_optionText)) . '</td>
<td class="table-carac-desc" style="padding-left: 45px !important;padding-right: 45px !important;"> ' . $newstr. '</td>
</tr>';
} else {
echo '<tr >
<td class="table-carac-title" style="padding-left: 45px !important;padding-right: 45px !important;">' . $_atribute->getFrontend_label() . '</td>
<td class="table-carac-desc" style="padding-left: 45px !important;padding-right: 45px !important;"> ' . $_optionText . '</td>
</tr>';
}
$count = $count + 1;
}
您可以在偶数行和奇数行上设置特定的css:
tr:nth-child(even) {background: #CCC}
tr:nth-child(odd) {background: #FFF}
您需要创建一个奇数和偶数的逻辑并添加到您的示例的 class 中:
$classtest = '';
if ($count % 2 == 0) {
$classtest = 'pair';
} else {
$classtest = 'odd';
}
在你的 TR 标签中:
'<tr class="active ' . $classtest . '">
您可以使用 $count 变量来设置每行要更改的颜色类型或其他值,如下所示:
if ( ($count % 2) == 0 )
$myColor = "color:black";
else
$myColor = "color:white";
# In you HTML element
echo sprintf('<tr style="%s"> ... something ... </tr>', $myColor);