我的网站设计有媒体查询以涵盖不同大小的布局。我有砌体组织一堆全尺寸宽度的花车,没问题。在移动宽度上,所有的浮动,取消浮动并且只是堆叠在彼此之上。所以我只需要在 768px <= width <= 1000px 时网站调整为平板电脑布局时重新运行砌体。
<script type="text/javascript">
//<![CDATA[
$(document).ready(function($){
$('ul.xoxo').masonry({ singleMode: true, itemSelector: '.widgetcontainer' });
//If the User resizes the window, adjust the #container height
$(window).bind("resize", resizeWindow);
function resizeWindow( e ) {
var newWindowWidth = $(window).width();
if(newWindowWidth<1008){
$('ul.xoxo').masonry();
} else {
$('ul.xoxo').masonry();
}
}
});
/* ]]> */
</script>
这对我还不起作用,但我也不希望它在所有调整大小时运行......只是在断点处。