Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
623 views
in Technique[技术] by (71.8m points)

css - Why border of <tr> not showing in IE?

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 not

table {
    border-collapse: collapse;
    border-spacing: 0;
}

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

HTML

<table cellpadding="0" cellspacing="0">
 <thead>
  <tr>
   <th align="left" scope="col">XXXX</th>
   <th align="right" scope="col">XXXX</th>
   <th align="right" scope="col">XXXX</th>
   <th align="right" scope="col">XXXX</th>
  </tr>
 </thead>
  <tfoot>
  <tr>
   <td colspan="3">XXXX</td>
   <td align="right">XXX</td>
  </tr>
   <tr>
   <td colspan="4">XXX</td>
   </tr>
 </tfoot>
 <tbody>
  <tr>
   <td align="left">XXXX</td>
   <td align="right">XXXX</td>
   <td align="right">XXXX</td>
   <td align="right">XXXX</td>
  </tr>
 </tbody>
</table>

update:

i'm using this doctype

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 {
    ...
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...