douqixia7942 2019-03-23 11:37
浏览 33
已采纳

如何在html 5中修复表格宽度?

Check this image:

https://ibb.co/MhtZLpG

The problem is in my table my last column of my table is off the screen

I have tried

<table style="width:200px !important">

and

<table style="width:20% !important">

but it didn't work.

  • 写回答

1条回答 默认 最新

  • dousi4472 2019-03-23 11:44
    关注

    You will need to set the table-layout explicitly:

    table {
      table-layout: fixed;
    }
    

    Then, you can set the column width:

    th:nth-child(<<the number of which column you want to set the width>>) {
      width: <<your desried width>>
    }
    

    And if you want to set the table width occupy the full width, then just set:

    table {
      table-layout: auto;
    }
    

    What you're trying to do is to make like:

    table {
      table-layout: fixed;
      width: 20%;
    }
    

    Using inline, the following will work:

    <table style="width:20%; table-layout: fixed;">
    

    Here's the width classes that bootstrap 4 comes with:

    w-25 /* width: 25%; */
    w-50 /* width: 50%; */
    w-75 /* width: 75%; */
    w-100 /* width: 100%; */
    

    To which you can apply to your table for the class. For eg. class="w-25"

    You can also apply the column classes - col-*:

    <table class="col-3">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办