[英]How to add TABLE style in QWEB reports? Odoo 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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.