2012-03-02 137 views
0

我正在使用第三方輪播,它可以實時添加內嵌寬度和高度樣式。當瀏覽器大小減小時,該站點使用媒體查詢來調整傳送帶容器的大小。我的問題是,頁面必須刷新的媒體查詢進來。所以我可以在調整大小刷新jQuery功能,以便重新制定其寬度/高度?刷新瀏覽器窗口上的一些jquery調整大小

這裏是jQuery的:

<script type="text/javascript"> 

    $(document).ready(function() { 

    $("#carousel").featureCarousel({ 
    // include options like this: 
    // (use quotes only for string values, and no trailing comma after last option) 
    carouselSpeed:700, 
    smallFeatureWidth:0.8, smallFeatureHeight:0.8, sidePadding:0, topPadding:0 
    }); 
    }); 
    </script> 

回答

4

使用window對象上resize()功能:

$(window).resize(function(){ 
    $("#carousel").featureCarousel({ 
     // include options like this: 
     // (use quotes only for string values, and no trailing comma after last option) 
     carouselSpeed:700, 
     smallFeatureWidth:0.8, smallFeatureHeight:0.8, sidePadding:0, topPadding:0 
    }); 
}); 

然後你可以使用$(window).height()$(window).width()讓您的新的大小和調整從那裏。

1

奇怪的是,我正在尋找刷新窗口重新大小爲完全相同的原因。我在一個響應式設計中有一個徽標滾動器,當窗口重新調整大小時,圖像堆疊在一起。對此的最佳解決方案如下: 1將卷軸放置在iframe中 2將類添加到帶有徽標滾動條的父頁上的iframe,並使用java在窗口大小調整時刷新iframe。

相關問題