开发者

Css classes in CakePHP?

How can I get a different css class for ea开发者_JAVA技巧ch table header?


I'm guessing you're looking for this?

echo $html->tableHeaders(
    array(
        array('Title for first cell', array('class' => 'class for first cell')),
        array('Title for second cell', array('id' => 'id for second cell')),
        array('Title for third cell', array('class' => 'thirdClass', 'id' => 'thirdId'))
    )
);


I don't really see the point of using the HTML helper for such task. It's just faster and more natural to simply write your own HTML table.

That being said, you could use a simple counter for your th

<?php $k = 0; ?>
<tr>
    <th class="classeOne classTwo<?php if($k++ % 2 == 0) echo ' alt'; ?>"> foo </th>
    ...
</tr>

If you're looking to have a totally different class for every header, you could do :

<?php
$thClasses = array(
                'classOne',
                'classTwo',
                'classThree');
$k = 0;
?>
<tr>
    <th class="<?php echo thClasses[$k++]; ?>"> foo </th>
    ...
</tr>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜