微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在 QWEB 报表中添加 TABLE 样式?奥多14

如何解决如何在 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>

我得到了这个结果:

enter image description here

但我想得到这种风格的表格:

enter image description here

请问有什么帮助吗?谢谢。

我尝试了这两种解决方案,但得到了以下结果:

enter image description here

<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>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。