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