Javascript 如何在HTML5中固定表格宽度?
检查此图像: 问题是在我的表格中,我表格的最后一列不在屏幕上 我试过了Javascript 如何在HTML5中固定表格宽度?,javascript,php,css,html,Javascript,Php,Css,Html,检查此图像: 问题是在我的表格中,我表格的最后一列不在屏幕上 我试过了 及 但是它不起作用。您需要明确设置表布局: table { table-layout: fixed; } 然后,可以设置列宽: th:nth-child(<<the number of which column you want to set the width>>) { width: <<your desried width>> } 你要做的是让自己像: t
及
但是它不起作用。您需要明确设置
表布局
:
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: fixed;
width: 20%;
}
使用内联,以下功能将起作用:
<table style="width:20%; table-layout: fixed;">
您可以将其应用于该类的表。例如class=“w-25”
您还可以应用列类-col-*
:
<table class="col-3">
例如,尝试在JSFIDLE中重现这种情况。如果我们看不到你的html结构或css代码,就很难解决问题。你是在使用bootstrap
还是jquery ui
我在使用bootstraphere是我的代码:Thnx Bhojendra Rauniyar先生,我真的很感谢你快速给出答案,但没有用我已经试过了什么不起作用?我已经尝试了包括大多数可能的方法。即使使用bootstrap,也不要忘了设置表格布局
。@Aeraz它可以工作,你哪里出错了,或者你在演示中忘记告诉我们什么了?我不知道我哪里做错了,但这对我来说不起作用,因为我帮助了很多人
w-25 /* width: 25%; */
w-50 /* width: 50%; */
w-75 /* width: 75%; */
w-100 /* width: 100%; */
<table class="col-3">