javascript - 如何在 QWEB 报表中添加 TABLE 样式?奥多 14
问题描述
我想为表格添加边框,
<table style="border: 1pt solid black;display: inline-block;">
<tbody style="">
<tr>
<th" >Title1</th>
<th" >Title2</th>
</tr>
<tr>
<td t-esc=""/>
<td t-esc=""/>
</tr>
</tbody>
</table>
但是当我尝试添加这种样式时:
<style>
td, th{border:solid 1px;text-align:center;}
</style>
请问有什么帮助吗?谢谢。
我尝试了这两种解决方案,但得到了以下结果:
<table class="table">
<tbody style="">
<tr>
<th >Title1</th>
<th >Title2</th>
</tr>
<tr>
<td > Field1 </td>
<td > Field2 </td>
</tr>
</tbody>
</table>
<table style=" border-collapse: collapse;">
<tbody >
<tr>
<th style=" border-collapse: collapse;" >Title1</th>
<th style=" border-collapse: collapse;" >Title2</th>
</tr>
<tr>
<td style=" border-collapse: collapse;" > Field1 </td>
<td style=" border-collapse: collapse;" > Field2 </td>
</tr>
</tbody>
解决方案
您需要使用额外的 css 属性,如下所示:
table, td, th{
border-collapse: collapse;
}
顺便说一句,在 Odoo 中,引导程序已包含在内,因此您可以执行以下操作:
<table class="table">
<table>
所以你的最终代码是
<!-- using bootstrap -->
<table class="table table-bordered ">
<tbody>
<tr>
<th>Title1</th>
<th>Title2</th>
</tr>
<tr>
<td> Field1 </td>
<td> Field2 </td>
</tr>
</tbody>
</table>
<!-- hard-coded style -->
<table style="border:solid 1px; border-collapse: collapse;">
<tbody>
<tr>
<th style="border:solid 1px; border-collapse: collapse;">Title1</th>
<th style="border:solid 1px; border-collapse: collapse;">Title2</th>
</tr>
<tr>
<td style="border:solid 1px; border-collapse: collapse;"> Field1</td>
<td style="border:solid 1px; border-collapse: collapse;"> Field2</td>
</tr>
</tbody>
</table>
推荐阅读
- r - 如何根据两个不同的条件为真用 ggplot 标记一个点?
- python - crontab Python 脚本中的“ImportError:没有名为请求的模块”
- python - pip install --upgrade pip 不是升级 pip
- javascript - 为什么点击提交按钮后无法清除数据?
- flutter - 如何创建相关图?
- c# - 拦截 SqlServerMigrationsSqlGenerator 以防止某些表的迁移?
- c# - 如何确定 String.Split() 中使用的字符
- c# - cshtml中的多对多关系没有获取数据
- python - 元组的问题
- arrays - 引用单元格数据作为工作表名称源的一部分的 Google 工作表查询