简体   繁体   English

HTML中多个表中相同列的相同[未固定]宽度

[英]same [not-fixed] width of same column in multiple tables in HTML

I have several tables on the same page, each with the same number of columns. 我在同一页面上有几个表,每个表都有相同的列数。 I want the first column in all the tables to have the same width, likewise for the second, etc. I do not want to specify a fixed width (eg, 100px), but rather let the browser calculate it. 我希望所有表中的第一列具有相同的宽度,同样适用于第二列,等等。我不想指定固定宽度(例如,100px),而是让浏览器计算它。 How can I accomplish this in HTML/XHTML/CSS/js? 如何在HTML / XHTML / CSS / js中完成此操作?

You could just specify the width to be a % of the total page width in the CSS. 您可以将宽度指定为CSS中总页面宽度的百分比。 Assign the same class to the first column in all the tables and set width: 15%; 将相同的类分配给所有表中的第一列并设置width: 15%; This isn't ideal however as the layout will vary based on a client's resolution. 然而,这并不理想,因为布局会根据客户的分辨率而有所不同。 You're better off using a fixed width with position: fixed; 你最好使用固定宽度的position: fixed;

see CSS class position CSS类的位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM