侧边栏在小屏幕的底部

我正在使用Shopisle主题。我已经在商店页面的左侧显示了产品类别下拉过滤器小部件。但是在较小的屏幕上, 它会自动在页面底部移动。如何在较小的屏幕顶部显示它?


#1


可以在窗口调整大小事件上使用一些JavaScript来完成。侧边栏实际上位于HTML标记的右侧(或更具体地, 位于下面)。它出现在左侧, 因为css的主要部分向右浮动。

调整大小时, css删除了宽度为767px的浮点数。因此, 侧栏跌至底部。

使用jQuery的insertBefore(http://api.jquery.com/insertbefore/)和insertAfter, 可以切换html标记。

注意:此示例移动了整个侧栏。如果有必要, 可以对其进行一些修改以仅移动单个小部件。这表示一般过程。

**顺便说一句, 该脚本应放在子主题的.js文件中。如果.js文件尚未存在, 请尝试将其添加到<script> … </ script>标记内的页脚模板文件中(最好在子主题中)。

var sidebar_at_top = false;
function formatdisplay(){
  if(jQuery( window ).width() < 768){
    if(!sidebar_at_top){
        console.log('moving sidebar to before main area');
            jQuery('.sidebar-shop').insertBefore(jQuery('.shop-with-sidebar'));
        sidebar_at_top = true;
    }
  }else{
    if(sidebar_at_top){
        console.log('moving sidebar to after main area');
            jQuery('.sidebar-shop').insertAfter(jQuery('.shop-with-sidebar'));
        sidebar_at_top = false;
    }
  }
}
jQuery( window ).resize(function() {
    formatdisplay();
});
jQuery( document ).ready(function() {
    formatdisplay();
});

来源:

https://www.srcmini02.com/65828.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_40775.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?