计算可拖动的div - jquery

发布于 2024-07-30 03:37:12 字数 285 浏览 1 评论 0原文

我的页面上有两个 div,代表两列。 两者都向左浮动,宽度为 49%,右内边距为 0.5%。 每列中都有垂直向下放置的各种 div。 现在我想创建一个函数,允许用户调整列中每个 div 的大小,或者如果无法实现,则创建一个允许用户调整每个列大小的函数。

我已经设法使列中的一个 div 可调整大小( $('#divid').ressized(); ),但我想修改脚本,因此自动计算处于打开状态。

解释。 如果用户将右列大小调整为 xx%,我希望左列大小减小 xx%

如何管理?

I have two divs on the page, which represent two columns.
Both are floating left, have 49% width and padding-right for 0.5%.
In each columns there are various divs positioned vertical down.
Now I want to make a function, which will allows user to resize each div in column, or if this isn't achieveable, a function which will allow user to resize each column.

I have managed to make one div in column resizable ( $('#divid').resizable(); ), but I want to modify script, so auto calculation is on.

To explain.
If user resize right columnn for xx%, I want that left column reduce size for xx%

How to manage this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

负佳期 2024-08-06 03:37:12

看一下 jQuery UI 可调整大小 元素。

Take a look at the jQuery UI Resizable element.

清醇 2024-08-06 03:37:12

jQuery 可调整大小的东西允许您指定一个 stop 回调。 我想最简单的事情就是编写一个回调来确定元素的像素大小,计算出相对大小,然后在元素上设置它。

这样做需要知道宽度或高度与哪个元素成比例,这对于自动确定可能并不简单。 您可能需要确保它是 HTML 中的特定元素; 也许为此目的添加一个特定的包含 div 。

The jQuery resizable thingy lets you specify a stop callback. I would imagine that the easiest thing to do, would be to write a callback that determines the pixel size of the element, and figures out the relative size and then sets that on the element.

Doing this is going to require knowing which element the width or height would be proportional to, which might not be trivial to determine automatically. You might need to make sure that it is a particular element in your HTML; maybe add a specific containing div for this purpose.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文