Statt den Schieber Effekt verwenden Sie die Größe Effekt verwenden:
$(function() {
$('#showdiv').click(function() {
$('.mydiv').show('size', { origin: ['top', 'center'] }, "slow");
});
$('#hidediv').click(function() {
$('.mydiv').hide('size', { origin: ['top', 'center'] }, "slow");
});
});
.ui-effects-wrapper {
height: auto !important;
}
.wrap {
}
.mydiv {
height: 100px;
padding: 15px 30px;
border: 2px solid;
background: orange;
}
.mydiv p {
padding: 10px 30px;
margin: -15px -30px 0;
background: yellow;
}
.below-div {
background: red;
padding: 10px 30px;
}
<link href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<button type="button" id="showdiv">
Slide Down
</button>
<button type="button" id="hidediv">
Slide Up
</button>
<div class="wrap">
<div class="mydiv">
<p>This is a div with long text; really extralong</p>
</div>
</div>
<div class="below-div">
This is a div below sliding div.
</div>
Sie können auch die belebte verwenden:
$(function() {
$('#showdiv').click(function() {
$('.mydiv').animate({ height: "show" }, 'slow');
});
$('#hidediv').click(function() {
$('.mydiv').animate({ height: "hide" }, 'slow');
});
});
.ui-effects-wrapper {
height: auto !important;
}
.wrap {
}
.mydiv {
height: 100px;
padding: 15px 30px;
border: 2px solid;
background: orange;
}
.mydiv p {
padding: 10px 30px;
margin: -15px -30px 0;
background: yellow;
}
.below-div {
background: red;
padding: 10px 30px;
}
<link href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<button type="button" id="showdiv">
Slide Down
</button>
<button type="button" id="hidediv">
Slide Up
</button>
<div class="wrap">
<div class="mydiv">
<p>This is a div with long text; really extralong</p>
</div>
</div>
<div class="below-div">
This is a div below sliding div.
</div>