table表头斜线

一、代码


<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>用div+css模拟表格对角线title>
    <style type="text/css">
        *{padding:0;margin:0;}
        caption{font-size:14px;font-weight:bold;}
        table{ border-collapse:collapse;border:1px #525152 solid;width:50%;margin:0 auto;margin-top:100px;}
        th,td{border:1px #525152 solid;text-align:center;font-size:12px;line-height:30px;}


        /*模拟对角线*/
        .out{
            border-top:40px #D6D3D6 solid;/*上边框宽度等于表格第一行行高*/
            width:0px;/*让容器宽度为0*/
            height:0px;/*让容器高度为0*/
            border-left:80px #BDBABD solid;/*左边框宽度等于表格第一行第一格宽度*/
            position:relative;/*让里面的两个子容器绝对定位*/
        }
        b{font-style:normal;display:block;position:absolute;top:-40px;left:-40px;width:35px;}
        em{font-style:normal;display:block;position:absolute;top:-25px;left:-70px;width:55x;}


    style>
head>
<body>
<table>
    <caption>用div+css模拟表格对角线caption>
    <tr>
        <th style="width:80px;">
            <div class="out">
                <b>类别b>
                <em>姓名em>
            div>
        th>
        <th>年级th>
        <th>班级th>
        <th>成绩th>
        <th>班级均分th>
    tr>
    <tr>
        <td class="t1">张三td>
        <td>td>
        <td>2td>
        <td>62td>
        <td>61td>
    tr>
    <tr>
        <td class="t1">李四td>
        <td>td>
        <td>1td>
        <td>48td>
        <td>67td>
    tr>
    <tr>
        <td class="t1">王五td>
        <td>td>
        <td>5td>
        <td>79td>
        <td>63td>
    tr>
    <tr>
        <td class="t1">赵六td>
        <td>td>
        <td>4td>
        <td>89td>
        <td>66td>
    tr>
table>
body>
html>

二、样式图

table表头斜线_第1张图片

你可能感兴趣的:(html5,CSS3,css)