Css visualcomposer中的粘滞行

Css visualcomposer中的粘滞行,css,sticky,Css,Sticky,我正在使用VisualComposer页面生成器在Wordpress中创建一个站点 我想将一行粘贴到页面顶部,并已将此CSS添加到编辑器中: /* makes header bar sticky to top of page */ .sticky { position: fixed; top: 0; z-index: 1; } 我添加了sticky作为类名 它不起作用,我也不知道我哪里出了问题?请帮忙 谢谢如果希望该行重叠所有内容,包括标题,则必须在DOM中移动该行并将其附加到页面

我正在使用VisualComposer页面生成器在Wordpress中创建一个站点

我想将一行粘贴到页面顶部,并已将此CSS添加到编辑器中:

/* makes header bar sticky to top of page */
.sticky {
  position: fixed;
  top: 0;
  z-index: 1;
}
我添加了sticky作为类名

它不起作用,我也不知道我哪里出了问题?请帮忙


谢谢

如果希望该行重叠所有内容,包括标题,则必须在DOM中移动该行并将其附加到页面正文中。否则,它将固定在其父容器中

jQuery(document).ready(function(){
    if (jQuery(".sticky").length) {
        jQuery(".sticky").appendTo("body");     
    }
});
假设上面的代码保存在根主题文件夹中“js”目录下名为“my scripts.js”的文件中,您可以确保在WordPress中的jQuery库之后使用以下函数正确地包含上述代码:

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');

注意:如果希望浏览器缓存脚本,请将
time()
替换为
false

如果希望该行与所有内容重叠,包括标题,则必须在DOM中移动该行并将其附加到页面正文中。否则,它将固定在其父容器中

jQuery(document).ready(function(){
    if (jQuery(".sticky").length) {
        jQuery(".sticky").appendTo("body");     
    }
});
假设上面的代码保存在根主题文件夹中“js”目录下名为“my scripts.js”的文件中,您可以确保在WordPress中的jQuery库之后使用以下函数正确地包含上述代码:

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');

注意:如果希望浏览器缓存脚本,请将
time()
替换为
false

您可以在父行中启用“sticky”来解决此问题

您可以在父行中启用“sticky”来解决此问题

您的意思是,要在“sticky”菜单栏顶部吗?请再举一个例子,你的意思是,你想在粘性菜单栏的顶端吗?请再举个例子