如何在wordpress

时间:2017-11-11 12:53:59

标签: css wordpress html5 twitter-bootstrap twitter-bootstrap-3

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

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

1 个答案:

答案 0 :(得分: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之类的位置:fixed;和z-index:9999;