您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

如何在HTML中创建一个折叠边框?

2025/4/23 23:57:47发布32次查看
我们使用 border-collapse 属性在 html 中创建折叠边框。 border-collapse 是一个 css 属性,用于设置表格边框应折叠为单个边框或在 html 中与其自己的边框分开。
border-collapse 属性有四个值:separate、collapse、initial、inherit。
随着价值崩溃如果将折叠作为 border-collapse 属性的值传递,则表格的边框将简单地折叠为单个边框。以下是在 html 中创建折叠边框的语法。
border-collapse: collapse;
示例 1在下面给出的示例中,我们尝试在 html 中创建折叠边框 -
<!doctype html><html><head> <meta charset=utf-8> <meta http-equiv=x-ua-compatible content=ie=edge> <meta name=viewport content=width=device-width, initial-scale=1.0> <style> table, tr, th, td { border: 1px solid black; border-collapse: collapse; } </style></head><body> <h2>tables in html</h2> <table style=width: 100%> <tr> <th>first name </th> <th>job role</th> </tr> <tr> <td>tharun</td> <td>content writer</td> </tr> <tr> <td>akshaj</td> <td>content writer</td> </tr> </table></body></html>
以下是上述示例程序的输出。
示例 2让我们看另一个例子,将折叠作为 border-collapse 属性的值 -
<!doctype html><html><head> <style> table {border-collapse: collapse; } table, td, th { border: 1px solid blue; } </style></head><body> <h1>technologies</h1> <table> <tr> <th>ide</th> <th>database</th> </tr> <tr> <td>netbeans ide</td> <td>mysql</td> </tr> </table></body></html>
以分离为值如果我们通过传递separate作为border-collapse属性的值来创建折叠边框,则各个单元格将被包裹在单独的边框中。
border-collapse:separate;
示例 1在下面给出的示例中,我们尝试在 html 中创建单独的折叠边框。
<!doctype html><html><head> <meta charset=utf-8> <meta http-equiv=x-ua-compatible content=ie=edge> <meta name=viewport content=width=device-width, initial-scale=1.0> <style> table,tr,th,td { border:1px solid black; border-collapse:separate; } </style></head><body> <h2>tables in html</h2> <table style=width: 100%> <tr> <th >first name </th> <th>job role</th> </tr> <tr> <td >tharun</td> <td >content writer</td> </tr> <tr> <td >akshaj</td> <td >content writer</td> </tr> </table></body></html>
以下是上述示例程序的输出。
示例 2让我们看另一个例子,其中将 split 作为 border-collapse 属性的值 -
<!doctype html><html><head> <style> table { border-collapse: separate; } table, td, th { border: 1px solid blue; } </style></head><body> <h1>technologies</h1> <table> <tr> <th>ide</th> <th>database</th> </tr> <tr> <td>netbeans ide</td> <td>mysql</td> </tr> </table></body></html>
以初始值作为值如果将 initial 作为 border-collapse 属性的值传递,它将设置为其默认值,即单独的。以下是语法,它使用 html 中的 border-collapse 属性的初始属性。
border-collapse:initial;
示例下面给出一个示例,它使用 html 中的 border-collapse 属性的初始属性。
<!doctype html><html><head> <meta charset=utf-8> <meta http-equiv=x-ua-compatible content=ie=edge> <meta name=viewport content=width=device-width, initial-scale=1.0> <style> table,tr,th,td { border:1px solid black; border-collapse:initial; } </style></head><body> <h2>tables in html</h2> <table style=width: 100%> <tr> <th >first name </th> <th>job role</th> </tr> <tr> <td >tharun</td> <td >content writer</td> </tr> <tr> <td >akshaj</td> <td >content writer</td> </tr> </table></body></html>
以上就是如何在html中创建一个折叠边框?的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product