如何创建具有可调整列的 HTML 表格?
我想知道如何创建一个可以调整列宽的表格。 我还没弄清楚该怎么做。 如果您知道这项技术的秘诀,请告诉我。
I want to know how to create a table where you can adjust the column widths. I have not figured out how to do this. If you know the secret sauce to this technique please let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
添加此 CSS 以使表格的列宽可调...
Add this CSS to make your table's column widths adjustable...
没有简单的答案,例如“使用一些 foobar html 属性”。
这是通过 javascript 和 DOM 操作完成的。
如果您想了解 Prototype 中此功能的实现,您可以查看 TableKit。
我确信那里有 jQuery 实现...我喜欢我的旧原型;)
There is no simple answer such as "use some foobar html property".
This is done with javascript and DOM manipulations.
If you are curious to see an implementation of this feature with Prototype you can take a look at TableKit.
I am sure there are jQuery implementations out there... I like my good old Prototype ;)
我相信这就像在单元格标题边缘的区域捕获鼠标单击事件一样简单,然后在拖动鼠标时动态更改列的宽度。
I believe it's as simple as capturing a mouse click event at an area at the edge of a cell header, and then dynamically changing the width of the column as the mouse is dragged.
你是在寻找outlook的效果还是有<-> 显示的内容是为了告诉您调整表格大小?
Are you looking for the effect of outlook or there is the <-> that show up to show you to resize the table?
Flexigrid for jQuery 看起来非常不错。
更新:根据 @Vincent 的评论,使用非常简单...请参阅该网站以获取完整的详细信息,但是对于最基本的示例 - 包括脚本,然后将功能挂接到您的表上:
或使用选项:
Flexigrid for jQuery seems pretty sweet.
Update: As per @Vincent's comment the use is really simple... see the site for full details, however for the most basic example - include the script then hook the functionality to your table:
or with options:
Yahoo UI (YUI) 数据表 小部件允许调整列大小。 它是公开可用的,但仍处于测试阶段,而且 YUI 库相当庞大。 任何实现都必须采用 JavaScript/DHTML,因为默认的 HTML 表不具备这种功能。
The Yahoo UI (YUI) data table widget allows resizing of columns. It's publicly available, but still in Beta, and the YUI library is pretty bulky. Any implementation will have to be in JavaScript/DHTML, because the default HTML tables don't have that kind of capabilities.
将
resize:horizontal
应用于不适用于我的 FF58。 相反,我在每个文件中创建了一个
并使其可调整大小:
Applying
resize:horizontal
to<th>
did not work with my FF58. Instead, I created a<div>
in each of them and made that resizable: