开发者

Applying CSS style to table cell when hovered over

开发者 https://www.devze.com 2023-03-31 20:02 出处:网络
I have a table that has a class, and some td elements inside of it. What is the correct CSS to give a hover effect on tds which are part of a table with some particular class?

I have a table that has a class, and some td elements inside of it. What is the correct CSS to give a hover effect on tds which are part of a table with some particular class?

<table class='some_class'>
    <tr>
        <td>123</td>
        <td>321</td>
    </tr>
</table>

What's the right CSS? T开发者_Python百科his is not working:

> .some_class td:hover { some style }


put this in your css file

body {
background-color: #ccc;
}

table.some_style td {
background-color: #0f0;
}

table.some_style td:hover {
background-color: #06c;
}

and this as your table

<table class="some_style">
<thead>
    <tr>
        <th>column one</th>
                    <th>column two</th>
                                <th>column three</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td>data one</td>
                    <td>data two</td>
                                <td>data three</td>
    </tr>
</tbody>


This is working for me table td:hover{ background : red; }

<table class='some_class'>
<tr>   
<td>123</td>
<td>321</td>
</tr>
</table>

I think your code should work also, maybe you didn't include css correctly , which browser do you use ???

0

精彩评论

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