我通過javascript更改我的元素的高度(無法通過css從0更改爲自動)。動畫後的響應自動高度容器
/* Function to animate height: auto */
function autoHeightAnimate(element, time){
var curHeight = element.height(), // Get Default Height
autoHeight = element.css('height', 'auto').height(); // Get Auto Height
element.height(curHeight); // Reset to Default Height
element.stop().animate({ height: autoHeight }, time); // Animate to Auto Height
}
後,我調整我的瀏覽器窗口中的元素不會自動改變其高度,因爲它只是我點擊標籤之一前後發生了改變。 DEMO here。
是否有可能通過CSS以某種方式做到這一點?如果不是如何通過JavaScript/jQuery來做到這一點,以便在縮放我的瀏覽器窗口後進行更改?
你爲什麼將其設置爲一個固定的高度,只是使其向'auto'擴大和'零時'而崩潰了。 – vivekkupadhyay
@vivekkupadhyay我做什麼?我把'autoHeight = element.css('height','auto')。height(); '使它自動。 –