[英]How to fix table width in html 5?
检查此图像:
问题出在我的表中,我表的最后一列不在屏幕上
我试过了
<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.