簡體   English   中英

如何修復html 5中的表格寬度?

[英]How to fix table width in html 5?

檢查此圖像:

https://ibb.co/MhtZLpG

問題出在我的表中,我表的最后一列不在屏幕上

我試過了

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

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

但它沒有用。

您需要明確設置table-layout

table {
  table-layout: fixed;
}

然后,您可以設置列寬:

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

如果你想設置表格寬度占據全寬,那么只需設置:

table {
  table-layout: auto;
}

你想要做的是像這樣:

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

使用內聯,以下將起作用:

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

這是 bootstrap 4 附帶的寬度類:

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

你可以申請到你的桌子上上課。 例如。 class="w-25"

您還可以應用列類 - col-*

<table class="col-3">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM