粘性行在Visual Composer中
问题描述:
我正在使用Visual Composer页面构建器在Wordpress中制作网站。粘性行在Visual Composer中
我想打一排粘到页面的顶部,增加了这个CSS来编辑:
/* makes header bar sticky to top of page */
.sticky {
position: fixed;
top: 0;
z-index: 1;
}
和我已经加入粘类名。
它不工作,我不知道我哪里出错了?请帮忙。
感谢
答
如果你想在该行重叠的一切,包括头,你要在DOM中移动它,并将其添加到页面的主体。否则,它在其父容器中变得固定。
jQuery(document).ready(function(){
if (jQuery(".sticky").length) {
jQuery(".sticky").appendTo("body");
}
});
上述假设被保存在一个名为“我的-scripts.js中”在根主题文件夹里面的“JS”目录中的文件,你可以确保你有上面的代码在WordPress jQuery库正确AFTER具有以下功能:
function my_jquery_scripts() {
$PathToMyScript = get_stylesheet_directory_uri() . "/js/my-scripts.js";
wp_register_script('my-jquery-js', $PathToMyScript, array('jquery'), time(), true);
wp_enqueue_script('my-jquery-js');
} add_action('wp_enqueue_scripts', 'my_jquery_scripts');
注意:如果您希望浏览器缓存你的脚本,与false
更换time()
。
你的意思是,你想顶部粘滞菜单栏?请举出更多的例子 –