CSS direct descendant “>” operator not working (and it's not IE6)?

后端 未结 1 1325
醉话见心
醉话见心 2021-01-11 21:02

I am trying to do something very simple - select the tags which are direct descendants of a tag.

The CSS I am using is as follows:

table.data >          


        
相关标签:
1条回答
  • 2021-01-11 21:30

    Most1 browsers automatically insert a tbody element into a table, so the css should be:

    table.data > tbody > tr { background-color: red; }
    

    to account for that.


    1 I think that all browsers do this, but I don't have the capacity, or time, to check that assumption. If you're concerned that there might be some users with a browser that doesn't do this, you could offer both selectors in the css:

    table.data > tr,
    table.data > tbody > tr { background-color: red; }
    
    0 讨论(0)
提交回复
热议问题