jQuery 可调整大小插件,仅调整高度

发布于 2024-10-06 07:49:19 字数 55 浏览 1 评论 0原文

如何使 alsoResize 选项仅适用于高度,而不适用于宽度和高度?

How to make alsoResize option to only work for height but not for both width and height?

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

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

发布评论

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

评论(3

梨涡 2024-10-13 07:49:19

实际上,如果您将 maxWidth 设置为限制,我们就无法调整宽度超过它。

例如,

$( ".selector" ).resizable({ maxWidth: 250 }); //For initialzation 

将不允许调整宽度超过 250px

如果您检查此演示,
http://jqueryui.com/demos/ressized/#max-min,你会注意到宽度调整被限制在一个点。

因此,在您的情况下,.selectormaxWidth 的初始宽度设置为相同,然后就完成了。

有关更多信息,请访问 http://jqueryui.com/demos/resizes/#option-maxWidth< /a>

Actually if you set maxWidth to a limit, we cannot resize the width more than it.

For example,

$( ".selector" ).resizable({ maxWidth: 250 }); //For initialzation 

will not allow the resize to occur more that 250px in width

If you check this demo
http://jqueryui.com/demos/resizable/#max-min, you will notice the width resizing being limited to a point.

So in your case set the initial width of the .selector and maxWidth same and it is done.

For further information go to http://jqueryui.com/demos/resizable/#option-maxWidth

给我一枪 2024-10-13 07:49:19

我假设你的基本元素是可调整大小的,可以在 x 和 x 中调整大小。 y 轴。使用alsoResize选项将对匹配元素应用相同的更改。我建议您不要使用alsoResize选项,而是使用resize事件处理程序手动应用更改。

I'm assuming that your base element that is resizable, can be resized in both the x & y axis. Using the alsoResize option will apply the same changes to the matching elements. I suggested you do not use the alsoResize option, but use the resize event handlers to apply the changes manually.

娇女薄笑 2024-10-13 07:49:19

只需转到插件代码并在此

添加: if (this.className == 'YOUR_ELEM_CLASS_OR_ID_NAME_HERE') css = ['height'];

之后

_alsoResize = function (exp, c) {
            $(exp).each(function() {
                var el = $(this), start = $(this).data("resizable-alsoresize"), style = {}, 
                    css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left'];

Just go to the plugin code and put this:

if (this.className == 'YOUR_ELEM_CLASS_OR_ID_NAME_HERE') css = ['height'];

right after this:

_alsoResize = function (exp, c) {
            $(exp).each(function() {
                var el = $(this), start = $(this).data("resizable-alsoresize"), style = {}, 
                    css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left'];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文