首页 > web前端 > css教程 > 表格细边框的两种CSS实现方法

表格细边框的两种CSS实现方法

巴扎黑
发布: 2017-04-05 09:46:17
原创
1062 人浏览过

在网页制作中,细边框这个制作方法是必不可少的。这里admin10000.com介绍2种常见的表格细边框制作方法,均通过XHTML验证。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>表格细边框的两种CSS实现方法</title>
        <style type="text/css">
                /* 利用表格样式 border-collapse: collapse 实现细边框 */
                .tab1
                {
                        width: 300px;
                        height: 200px;
                        border: 1px solid #ccc;
                        border-collapse: collapse;
                }
                .tab1 td, .tab1 th
                {
                        border: 1px solid #ccc;
                        padding: 5px;
                }
                /* 利用表格样式 border-spacing:0px; 和表格与单元格背景色的不同来实现细边框。
                 IE7及更早浏览器不支持border-spacing属性,可以通过table的标签属性cellspacing来替代。*/
                .tab2
                {
                        width: 300px;
                        height: 200px;
                        background-color: #ccc;
                        border-spacing: 1px;
                }
                .tab2 td, .tab2 th
                {
                        background-color: #fff;
                }
        </style> 
</head> 
<body>
        第一种 (通过XHTML验证)
        <table class="tab1">
                <thead>
                        <tr>
                                <th>
                                        表头
                                </th>
                                <th>
                                        表头
                                </th>
                        </tr>
                </thead>
                <tr>
                        <td>
                                Admin10000.com
                        </td>
                        <td>
                                Admin10000.com
                        </td>
                </tr>
                <tr>
                        <td>
                                Admin10000.com
                        </td>
                        <td>
                                Admin10000.com
                        </td>
                </tr>
        </table>
        <br />
        <br />
        第二种 (通过XHTML验证)
        <table class="tab2">
                <thead>
                        <tr>
                                <th>
                                        表头
                                </th>
                                <th>
                                        表头
                                </th>
                        </tr>
                </thead>
                <tbody>
                        <tr>
                                <td>
                                        Admin10000.com
                                </td>
                                <td>
                                        Admin10000.com
                                </td>
                        </tr>
                        <tr>
                                <td>
                                        Admin10000.com
                                </td>
                                <td>
                                        Admin10000.com
                                </td>
                        </tr>
                </tbody>
        </table> 
</body> 
</html>
登录后复制

相关文档:用CSS hack技术解决浏览器兼容性问题

以上是表格细边框的两种CSS实现方法的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板