Tag: scale

如果缩放,Jquery可放置区域错误

这是评论的小提琴: http : //jsfiddle.net/7xw1m1qd/1/ 以Html为例: JS例如: $(‘.drag’).draggable({}); $(‘.droppable’).droppable({ out: function() { $(‘.drag’).css(‘background-color’, ‘red’); }, drop: function() { $(‘.drag’).css(‘background-color’, ‘green’); }, }); CSS例如: .droppable { width: 200px; height: 200px; transform: scale(2); -webkit-transform: scale(2); -ms-transform: scale(2); background-color: #C3C3C3; } .drag { background-color: black; width: 20px; height: 20px; z-index: 10; position: absolute; top: 10px; left: 350px; } 问题是:如果droppable被缩放(通过transform:scale),它仍然使用droppable的原始尺寸,所以我只能在droppable的原始边界中删除元素。 […]

使用jQuery按比例调整iframe大小以适应DIV

我在div中有一个video的iframe,如下所示: 我在窗口resize时动态设置DIV的大小。 我想缩放iframe以适应div内部, 同时保持它的纵横比 。 大多数代码处理缩放图像,这更容易。 这是我到目前为止,但它不起作用: jQuery.fn.fitToParent = function() { this.each(function() { var width = jQuery(this).width(); var height = jQuery(this).height(); var parentWidth = jQuery(this).parent().width(); var parentHeight = jQuery(this).parent().height(); if(width < parentWidth) { newWidth = parentWidth; newHeight = newWidth/width*height; } else { newHeight = parentHeight; newWidth = newHeight/height*width; } jQuery(this).css({ 'height' :newHeight, 'width' :newWidth' }); […]