可折叠、可调整大小的 jQuery-ui 选项卡小部件
我一直在尝试创建一组可折叠且可调整大小的选项卡。我遇到的问题是,调整大小后(在演示中拖动顶部边缘),当您单击活动选项卡将其关闭时,内容会消失,但选项卡容器保持相同的大小,而不是缩小以适合选项卡栏。
使选项卡容器在调整大小后缩小的技巧是什么?
I've been trying to create a set of tabs that is collapsible and also resizable. The problem I'm having is that after resizing (dragging top edge in demo) when you click the active tab to close it, the content disappears but it the tabs container stays the same size instead of shrinking to fit just the tab bar.
What's the trick to making the tabs container shrink after it's been resized?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用 Firefox 的 Web 开发工具栏追踪到了这一点。我在调整大小之前和之后执行了“查看生成的源”,并在输出上运行
diff
。调整大小会向受影响的元素添加样式属性:为了解决此问题,我添加了
tabsselect
事件的处理程序。当折叠 div 时,它会将top
和height
存储到数据属性中,然后将其删除。显示选项卡时,它会从数据属性恢复设置。I tracked this down using Firefox's Web Developer Toolbar. I did "View Generated Source" before and after resizing and ran
diff
on the output. Resizing adds a style attribute to the affected element:To account for this I added a handler for the
tabsselect
event. It storestop
andheight
into data attributes when collapsing the div and then removes them. When showing a tab it restores the settings from the data attributes.