表头/正文宽度问题
我有一个表格,其中有标题行和正文内容的几行。
现在这些实际上是两个单独的表:
- 标题
- 对于正文内容的
(它是另一个 iframe 的一部分),我希望列标题及其相应的正文内容的宽度应该相同。
如何确保两个宽度相似并且外观相似,就好像它们是同一张表的一部分一样?
我对 CSS 或 Javascript 修复持开放态度。
注意:我将无法使用固定的列宽度,而且我也无法控制合并到一个表中...
I have a table which has a header row and few rows for the body content.
Now these are actually 2 separate tables:
- for Header
- for Body content (which is part of another iframe)
I want that the widths should be same for the column header and it's corresponding body content.
How can I ensure that both the widths are similar and the appearance would be similar as if they are part of the same table?
I am open to both CSS or Javascript fix..
Note: I'll not be able to use fixed col widths AND neither do I have control to merge into one table...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
也许是这样的?这将使你的表表现得好像在那里一个
几乎忘记我在这里使用我自己的一些功能,这里也来了
Maybe something like this? This will make your tables act as if thay where one
Almost forgot im using some of my own functions here, here thay come aswell
我有点同意罗德里戈的观点,尽管我会设置最大宽度和最小宽度,而不仅仅是像这样的宽度:
否则,实际大小可能取决于表格单元格内容和可用空间。
I sort of agree with Rodrigo, although I would set max-width and min-width, rather than just width like so:
Otherwise, the actual size can depend on the table cell content and available space.
如果表格的“流动性”并不重要,您可以为每个列定义类并使用 css 设置它们的样式。例如:
等等。
编辑:这里是我刚刚发现的一个例子,它使用CSS来实现这种效果。
If it is not important that the table be "fluid", you can define classes for each of your columns and style them with css. Ex:
and so on.
Edit: here is an example I just found that uses CSS to achieve this effect.
如果可以的话,您应该使用
和
。
除非有特殊原因需要单独的表,否则这样做会简单得多。
You should be using
<thead>
and<tbody>
if you can.Unless there's a reason you have separate tables, it would be much simpler to do it this way.