2017-11-11 225 views
-1

我想在我的WordPress网站上添加粘贴栏。我通过不同网站上提供的材料多次尝试过,但从未成功。如何在wordpress上添加粘边栏

我不想使用WordPress插件,因为大多数此类插件未更新多年。

+0

有任何我们的代码? – lumio

回答

0

您可以通过使用jQuery

添加动态类呢?这是我在我的上滚动的动态类中添加一个站点使用的示例代码。

$(window).scroll(function() { 

       var scroll = $(window).scrollTop(); 

       if (scroll > 100) { // This is scroll height you can change as per your need 

        $(".mobile_menu").addClass("sticky-sidebar"); // sticky-header is class which will add and mobile_menu is the base class where sticky-header will be added. 

       } else { 

        $(".mobile_menu").removeClass("sticky-sidebar"); 

       } 

      }); 

enter image description here

enter image description here

在最后需要添加CSS一样的位置是:固定;和z-index:9999;

+0

嗨,感谢您的及时回复。你能告诉哪里放这些代码?我将jQuery放在侧栏上的其他CSS和div上。但仍然无法工作 –

+0

如果您在wordpress中添加此代码,那么您可以添加footer.php或通过在页眉或页脚中调用新的js文件 –