我正在嘗試動態創建div,我將其設置爲width
至650px
,當我「縮小」它時,我想在切換動畫時恢復其原生width
。您可以看到我的animated_div
,有容器的width
,並且只有一個min-width
集合。這是我的代碼:恢復未設置的div寬度
HTML
<div id="container>
<div class="animated_div>
...
<p>really a lot of text here</p>
...
</div>
</div>
CSS
.animated_div{
padding:20px;
min-width:650px;
margin:0 auto;
margin-bottom:15px;
margin-top:10px;
}
JQUERY
$("#toggle_click").on('click', function() {
$("#animated_div").animate({
width : "650px"
})
$("#toggle_click2").on('click', function() {
$("#animated_div").animate({
width : "100%" // Here it is the problem , It set the div to be over-widthed.
})
的問題,因爲我在評論中寫道,如果我設置100%
div比容器獲得更多的寬度。
我相信你要找的東西是設置'width:auto'。你有一個顯示問題的jsfiddle嗎? – 2013-03-07 20:26:32
我已經嘗試使用自動,它不工作 – steo 2013-03-07 23:16:07