2014-02-22 125 views
0

我使用jQueryUI的,这是fiddle example
我的问题是,你可以在我的小提琴看到,在resizable DIV的文本行是相互重叠和我的div可以拖动只是一个时间
我该如何解决这个问题?jQueryUI的可拖动和可调整大小的盒子问题

的Javascript

var DEF_HEIGHT = 100; // the #resizable default height 
$("#resizable").resizable({ 
    containment: 'parent',handles: "se",stop:resizeStop, 

    aspectRatio: true, 
    resize: function(event, ui) {   
    var curHeight = (ui.size.height/ DEF_HEIGHT) * 100; 

    $(this).css('font-size', curHeight + '%'); 
    } 
}).draggable({containment: 'parent', stop:dragStop}); 

function dragStop(event, ui){ 
    convert_to_percentage($(this)); 
} 

function resizeStop(event, ui){ 
    convert_to_percentage($(this)); 
} 

CSS

#container { 

    background:black; 
    position:relative; 
    margin:0; 
    line-height:0; 
    text-align:center; 
} 
#resizable { 
    width: 200px; 
    height: 100px; 
    padding: 10px; 
    font-size: 100%; 
    position:absolute !important; 
} 
+2

问题是在convert_to_percentage如果你删除它会起作用,是否定义了这个函数?它没有在小提琴中定义,也许这是问题 – Reda

回答

2

1)你的行高为0,这是行重叠的原因。

2)您使用的功能“convert_to_percentage”,这是不存在于你的代码,这是你只能将它拖动一次

function dragStop(event, ui){ 
    convert_to_percentage($(this)); 
} 

function resizeStop(event, ui){ 
    convert_to_percentage($(this)); 
} 

看一看这样做的原因:http://jsfiddle.net/YxcS8/

相关问题