border-collapse属性是用于表格元素的, 可以用来设置表格的两边框合并为一个单一的边框。所有主流浏览器都支持 border-collapse 属性。

css border-collapse属性怎么用?
border-collapse 属性设置表格的边框是否被合并为一个单一的边框,还是像在标准的 HTML 中那样分开显示。
语法:
立即学习“前端免费学习笔记(深入)”;
border-collapse: separate|collapse|inherit;
属性值:
● separate:默认值。边框会被分开。不会忽略 border-spacing 和 empty-cells 属性。
● collapse:如果可能,边框会合并为一个单一的边框。会忽略 border-spacing 和 empty-cells 属性。
● inherit:规定应该从父元素继承 border-collapse 属性的值。
注释:所有主流浏览器都支持 border-collapse 属性。任何的版本的 Internet Explorer (包括 IE8)都不支持属性值 "inherit"。如果没有规定 !DOCTYPE,则 border-collapse 可能产生意想不到的结果。
css border-collapse属性 示例
<!DOCTYPE>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
table{
border-collapse:collapse;
}
table, td, th{
border:1px solid black;
}
</style>
</head>
<body>
<table>
<tr>
<th>姓名</th>
<th>年龄</th>
</tr>
<tr>
<td>Bill</td>
<td>20</td>
</tr>
<tr>
<td>Steven</td>
<td>25</td>
</tr>
</table>
</body>
</html>效果图:

以上就是css border-collapse属性怎么用的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号