我正在尝试使可排序的div垂直调整大小。当可以排序时,将考虑该类的所有内容,包括调整大小的句柄。另外,jQuery UI函数可以正常工作。
我还尝试过使用:
和div作为我的“幻灯片”的包装程序在CSS中使用处理程序,但是我相信有更好的方法。
我尝试过调整CSS大小。
我已经在类中尝试了jQUery UI可调整大小的函数。
.ui-resizable-handle
$(".slides").sortable({
placeholder: 'slide-placeholder',
axis: "y",
revert: 150,
start: function(e, ui) {
placeholderHeight = ui.item.outerHeight();
ui.placeholder.height(placeholderHeight + 15);
$('<div class="slide-placeholder-animator" data-height="' + placeholderHeight + '"></div>').insertAfter(ui.placeholder);
},
change: function(event, ui) {
ui.placeholder.stop().height(0).animate({
height: ui.item.outerHeight() + 15
}, 300);
placeholderAnimatorHeight = parseInt($(".slide-placeholder-animator").attr("data-height"));
$(".slide-placeholder-animator").stop().height(placeholderAnimatorHeight + 15).animate({
height: 0
}, 300, function() {
$(this).remove();
placeholderHeight = ui.item.outerHeight();
$('<div class="slide-placeholder-animator" data-height="' + placeholderHeight + '"></div>').insertAfter(ui.placeholder);
});
},
stop: function(e, ui) {
$(".slide-placeholder-animator").remove();
},
});
body {
padding: 20px;
}
.slides {
list-style: none;
margin: 0;
padding: 0;
width: 300px;
}
.slideBody {
background-color: white;
}
.slides {
list-style: none;
margin: 0;
padding: 0;
width: 300px;
}
.slide {
padding: 15px;
background-color: #2F2F2F;
margin: 0 0 15px;
text-align: center;
color: #FFF;
border: 2px solid #444;
resize: vertical;
overflow: auto;
}
.slide-placeholder {
background: #DADADA;
position: relative;
}
.slide-placeholder:after {
content: " ";
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 15px;
background-color: #FFF;
}
.slide2 {
height: 30px;
}
.slide3 {
height: 50px;
}
.slide4 {
height: 90px;
}
.slide5 {
height: 35px;
}
答案 0 :(得分:1)
除Resizable Interaction之外,我还建议使用jQuery UI Sortable Interaction。
$(".slides").sortable({
axis: "y"
});
$('.slide').resizable({
handles: 'n, s'
});
body {
padding: 20px;
}
.slides {
list-style: none;
margin: 0;
padding: 0;
width: 300px;
}
.slide {
padding: 15px;
background-color: #2F2F2F;
margin: 0 0 15px;
text-align: center;
color: #FFF;
border: 2px solid #444;
}
.slide2 {
height: 30px;
}
.slide3 {
height: 50px;
}
.slide4 {
height: 90px;
}
.slide5 {
height: 35px;
}
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<div class="slides">
<div class="slide slide1">Slide 1</div>
<div class="slide slide2">Slide 2</div>
<div class="slide slide3">Slide 3</div>
<div class="slide slide4">Slide 4</div>
<div class="slide slide5">Slide 5</div>
</div>