Why doesn't CSS hover work on table rows when the cells inside the rows have class names?

前端 未结 6 1917
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-04 02:13

I am stuck with this problem so any help would be appreciated. I have a table with several rows. Each cell within the row belongs to a certain class. I use these class names to

相关标签:
6条回答
  • 2021-02-04 02:21

    You probably need to use the !important designator to make sure that your hover style overrides the background defined int he class:

    tr:hover { 
        background-color: #FFFFAF0 !important;
        color: #000 !important; 
    } 
    

    Interestingly, this won't work for IE6 because that browser only applies hover to a tags.

    0 讨论(0)
  • 2021-02-04 02:23

    The CSS instructions within the classname takes precedence over the <tr> instructions.

    To fix this, use td.summarypage-odd-column:hover, td.summarypage-even-column:hover inside your CSS.

    Note: If you're using IE6, the :hover only works on links, i.e. a:hover.

    0 讨论(0)
  • 2021-02-04 02:28

    never put space between

    tr:hover(space)td
    

    I was giving space hence it was working for me.

    0 讨论(0)
  • 2021-02-04 02:29

    Try this:

    tr:hover td {
      background-color: #FFFAF0; color: #000;
    }
    

    Place this after the existing td style declarations to be safe

    0 讨论(0)
  • 2021-02-04 02:38

    I think the td background-color overwrites the tr background-color. The solution given by @Nick Craver is the good one.
    You must change cells background-color not the row background-color.

    tr:hover td {
       ...
    }
    
    0 讨论(0)
  • 2021-02-04 02:42

    This does not happen for me. Make sure that you're only adding/removing class names when checking if they have an impact, and make sure that the tds don't have their own background covering up that of the tr.

    0 讨论(0)
提交回复
热议问题