jquery 使用animate來改變高度時會自動在樣式添加overflow:hidden

使用jQuery animate做自定義動畫,動畫裏面改變高度,發現瀏覽器訪問時會自動在樣式添加overflow:hidden。

被這問題坑慘了,始終找不到原因,後來百度才知道:

jQuery 的 anmiate 會自動添加overflow:hidden;

這時候在css中這樣寫 overflow:visible !important;

(也就是在哪個元素做動畫就在哪個元素的css裏寫這個屬性)

注意啊 如果寫在行內樣式 還是會被覆蓋;

css代碼:

ul li {
            width: 69px;
            height: 69px;
            float: left;
            margin-left: 10px;
            position: relative;
            overflow: visible !important;
        }

 

 

 

 

 

js代碼:

$(function () {
            $('li').mouseenter(function () {
        
                $(this).stop().animate({
                        width: 224,
                    }).find('.small').stop().fadeOut().siblings()
                    .stop().fadeIn();
             
            })
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章