【发布时间】:2016-03-28 07:29:10
【问题描述】:
我正在尝试通过单击增加和减少图标来调整模式窗口的大小。在每次 increase/decrease 点击后,模态框也应该位于屏幕中间。
到目前为止,只有增加是有效的。谁能解释我做错了什么?
this.increaseModal = function () {
var maxHeight = ($(window).height() * 90) / 100;
var maxWidth = ($(window).width() * 90) / 100;
var height = ($(window).height() * 10) / 100;
var width = ($(window).width() * 10) / 100;
if ($('.modal-content').height() <= maxHeight - 100) {
$('.modal-content').height($('.modal-content').height() + height);
increaseHeightCount = increaseHeightCount + 1;
}
if ($('.modal-content').width() <= maxWidth - 100) {
$('.modal-content').width($('.modal-content').width() + width);
increaseWidthCount = increaseWidthCount + 1;
}
$('.modal-dialog').draggable();
$('#myModal').addClass('outPopUp');
}
this.decreaseModal = function () {
var maxHeight = ($(window).height() * 90) / 100;
var maxWidth = ($(window).width() * 90) / 100;
var height = ($(window).height() * 10) / 100;
var width = ($(window).width() * 10) / 100;
if (increaseWidthCount > 0) {
$('.modal-content').width($('.modal-content').width() - width);
increaseWidthCount = increaseWidthCount - 1;
}
if (increaseHeightCount > 0) {
$('.popup').height($('.popup').height() - height);
increaseHeightCount = increaseHeightCount - 1;
}
}
outPopUp 是我覆盖引导 css 以更改模式窗口位置的类。
据我在 DOM 资源管理器中看到的,.popup 没有分配给元素,因此增加/减少高度不起作用。
【问题讨论】:
-
你好,增加有效吗?因为在顶部,您说正在工作,但在底部您说不工作。您还可以显示弹出窗口的 html 吗?谢谢!
-
进一步了解@dsg 所写的内容,请创建一个fiddle 或(甚至更好)在您的问题中添加一个sn-p,以便我们看到问题所在。见how to ask
-
点击增加图标时,模态宽度正在增加..而不是高度。减少根本不起作用,定位不会改变到屏幕中间。
-
这是我刚刚创建的小提琴jsfiddle.net/569n1mh4
-
是我自己还是模态根本无法拖动或调整大小?
标签: jquery html angularjs twitter-bootstrap bootstrap-modal