所以我有一个导航菜单,可以在纵向或横向观看平板电脑时改变风格.它将最后几个菜单项折叠到另一个下拉菜单中.然而,菜单不会在方向更改时更新,仅在刷新后才会更新.
Jquery Modernizr代码:
if(Modernizr.mq('(max-device-width: 800px) and (orientation: portrait)')){
// portrait stuff
// unhides last few menu items
$('#menu-primary-items > li:nth-last-child(-n+3)').css('display', 'block');
// remove hide and first child class originally assigned to it from it's ul parent
// then add the more list item to the end of the nav menu
$('.moreItem').removeClass('hide first-child').appendTo('#menu-primary-items');
// grab the last two items of the nav menu and insert into the more list item menu
$('.topNavigation .toplevel').slice(-2).appendTo('.moreMenu');
}
Run Code Online (Sandbox Code Playgroud)
有什么建议??