开发者

css background change for tr

开发者 https://www.devze.com 2023-03-04 14:44 出处:网络
I want to give good background effect to rows using this css tr:hover td{background-color:#ddd; } imagine a table inside a table,

I want to give good background effect to rows using this css

tr:hover td{background-color:#ddd; }

imagine a table inside a table, naturally all td's inside, also effected by this css. How can I prevent?

<table
    <tr
        <td -->color change is good
    <tr
        <td
            <table
                <tr
                    <td --> color change is bad

I tried using

开发者_如何学运维
form>table>tr:hover td still same
form>table>tr:hover>td not working at all

thanks for help


Use this to style only your outer tds on hover.

form > table > tbody > tr:hover > td {
    background-color: #ddd;
}

Notice the tbody selector. See this answer for why it's needed.


Use a second selector:

tr:hover table td { background-color: black; } /*change to default*/
0

精彩评论

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