在 layui 中改變表格背景色,需要在 css 中設(shè)置 .layui-table 類的 background-color 屬性。具體步驟如下:html 中使用 layui 表格組件。css 中設(shè)置表格背景色,如:.layui-table { background-color: #f5f5f5; }。
如何在 layui 中改變表格背景色?
在 layui 中改變表格背景色可以通過設(shè)置 .layui-table
類的 background-color
屬性。
步驟:
在 HTML 中使用 layui 的表格組件:
<code class="html"><table class="layui-table"> <thead><tr> <th>ID</th> <th>姓名</th> <th>郵箱</th> </tr></thead> <tbody> <tr> <td>1</td> <td>張三</td> <td>[email protected]</td> </tr> <!-- ... 其他行 --> </tbody> </table></code>
登錄后復(fù)制
在 CSS 中設(shè)置表格背景色:
<code class="<a style='color:#f60; text-decoration:underline;' href=" https: target="_blank">css">.layui-table { background-color: #f5f5f5; // 設(shè)置背景為淺灰色 }</code>
登錄后復(fù)制
示例:
<code class="css">.layui-table { background-color: #f5f5f5; } .layui-table-header { background-color: #e6e6e6; // 設(shè)置表頭背景為淡灰色 } .layui-table-cell { background-color: #fff; // 設(shè)置單元格背景為白色 }</code>
登錄后復(fù)制
通過上述 CSS 代碼,表格的背景色將變?yōu)闇\灰色,表頭背景變?yōu)榈疑鴨卧癖尘皠t為白色。