【发布时间】:2015-11-10 15:29:18
【问题描述】:
在这里,我正在尝试创建一个动画div 容器,该容器将根据内容大小和动画调整自身大小。问题是尺寸不能轻易计算,这使得很难使用常见的建议。
我在下面的链接上重现了整个问题,我正在寻找找到解决方案的提示。
https://jsfiddle.net/csj78rgo/2/
我首选的解决方法是 jQuery、jQuery-ui 或 Bootstrap JS。
HTML:
<div class="container">
<div id="part1">
<h3>TITLE</h3>
<p>Some content</p>
<p>Some content</p>
</div>
<div id="part2">
<p>Some content</p>
</div>
<div id="part3">
<p>Some content</p>
<p>Some content</p>
</div>
</div>
JS:
step = 0;
if (step==0) {
$('#part1').show();
$('#part2').hide();
$('#part3').hide();
} else if (step==1) {
$('#part1').hide();
$('#part2').show();
$('#part3').hide();
} else if (step==2) {
$('#part1').hide();
$('#part2').hide();
$('#part3').show();
}
CSS:
.container {
border: 1px black solid
}
【问题讨论】:
-
不清楚您在寻找什么,可能是这样的:jsfiddle.net/csj78rgo/1?
-
是的,你得到了我正在寻找的解决方案,你能把它贴在这里...
标签: javascript jquery jquery-ui jquery-animate containers