<p class="sycode"> <br> <br> </p> <br> <title>用div css模拟表格对角线</title> <br> <style type="text/css"> <br /> *{padding:0;margin:0;} <br /> caption{font-size:14px;font-weight:bold;} <br /> table{ border-collapse:collapse;border:1px #525152 solid;width:50%;margin:0 auto;margin-top:100px;} <br /> th,td{border:1px #525152 solid;text-align:center;font-size:12px;line-height:30px;background:#C6C7C6;} <br /> th{background:#D6D3D6;} <br /> /*模拟对角线*/ <br /> .out{ <br /> border-top:40px #D6D3D6 solid;/*上边框宽度等于表格第一行行高*/ <br /> width:0px;/*让容器宽度为0*/ <br /> height:0px;/*让容器高度为0*/ <br /> border-left:80px #BDBABD solid;/*左边框宽度等于表格第一行第一格宽度*/ <br /> position:relative;/*让里面的两个子容器绝对定位*/ <br /> } <br /> b{font-style:normal;display:block;position:absolute;top:-40px;left:-40px;width:35px;} <br /> em{font-style:normal;display:block;position:absolute;top:-25px;left:-70px;width:55x;} <br /> .t1{background:#BDBABD;} <br /> </style> <br> <br> <br> <table> <br> <caption>用div css模拟表格对角线</caption> <br> <tr> <br> <th style="width:80px;"> <br> <div class="out"> <br> <b>类别</b> <br> <em>姓名</em> <br> </div> <br> </th> <br> <th>年级</th> <br> <th>班级</th> <br> <th>成绩</th> <br> <th>班级均分</th> <br> </tr> <br> <tr> <br> <td class="t1">张三</td> <br> <td>三</td> <br> <td>2</td> <br> <td>62</td> <br> <td>61</td> <br> </tr> <br> <tr> <br> <td class="t1">李四</td> <br> <td>三</td> <br> <td>1</td> <br> <td>48</td> <br> <td>67</td> <br> </tr> <br> <tr> <br> <td class="t1">王五</td> <br> <td>三</td> <br> <td>5</td> <br> <td>79</td> <br> <td>63</td> <br> </tr> <br> <tr> <br> <td class="t1">赵六</td> <br> <td>三</td> <br> <td>4</td> <br> <td>89</td> <br> <td>66</td> <br> </tr> <br> </table> <br> <div><a href="http://www.999jiujiu.com/"> http://www.999jiujiu.com/</a></div> <br> <br>