Why border of not showing in IE?

前端 未结 3 1398
南方客
南方客 2020-12-11 08:23

Why border of tfoot tr:first-child not showing in IE. I\'m checking in IE7.

font-weight:bold; background:yellow is showing in IE but border

相关标签:
3条回答
  • 2020-12-11 08:46

    http://www.w3schools.com/css/pr_pseudo_first-child.asp

    Note: For :first-child to work in IE, a DOCTYPE must be declared

    Add something like:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    

    And it should work

    0 讨论(0)
  • 2020-12-11 08:49

    I would avoid styling tr elements because they don't really "exist" as such, apart from for semantic reasons. You're better off targeting the table cells themselves, with something like this:

    table tfoot tr:first-child th,
    table tfoot tr:first-child td {
        font-weight:bold;
        background:yellow;
        border-top:2px solid red; 
        border-bottom:2px solid red;
    }
    

    Also, since you are targeting directly nested elements, you can use the child selector, which is faster for browsers to parse (they only have to search one level up/down).

    table > tfoot > tr:first-child > th,
    table > tfoot > tr:first-child > td {
        ...
    }
    
    0 讨论(0)
  • 2020-12-11 08:50

    Give position as relative for tr class, which will fix.

    tfoot tr {position:relative; border-bottom:solid 1px #ccc; }

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