gpt4 book ai didi

php - 向下滚动时如何停止页面顶部的导航栏

转载 作者:行者123 更新时间:2023-11-28 01:54:16 24 4
gpt4 key购买 nike

我想在向下滚动时让我的导航栏停止在页面顶部。

我知道 Jquery 以某种方式参与了解决方案,但我真的不知道如何使用它!

这是我的 header.php 文件(我在 wordpress CMS 上):

>
    <?php if (has_nav_menu('top-menu', 'responsive')) { ?>
<?php wp_nav_menu(array(
'container' => '',
'fallback_cb' => false,
'menu_class' => 'top-menu',
'theme_location' => 'top-menu')
);
?>
<?php } ?>

<?php responsive_in_header(); // header hook ?>

<?php if ( get_header_image() != '' ) : ?>

<div id="logo">
<a href="<?php echo home_url('/'); ?>"><img src="<?php header_image(); ?>" width="<?php if(function_exists('get_custom_header')) { echo get_custom_header() -> width;} else { echo HEADER_IMAGE_WIDTH;} ?>" height="<?php if(function_exists('get_custom_header')) { echo get_custom_header() -> height;} else { echo HEADER_IMAGE_HEIGHT;} ?>" alt="<?php bloginfo('name'); ?>" /></a>
</div><!-- end of #logo -->

<?php endif; // header image was removed ?>

<?php if ( !get_header_image() ) : ?>

<div id="logo">
<span class="site-name"><a href="<?php echo home_url('/'); ?>" title="<?php echo esc_attr(get_bloginfo('name', 'display')); ?>" rel="home"><?php bloginfo('name'); ?></a></span>
<span class="site-description"><?php bloginfo('description'); ?></span>
</div><!-- end of #logo -->

<?php endif; // header image was removed (again) ?>

<?php get_sidebar('top'); ?>
<?php wp_nav_menu(array(
'container' => 'div',
'container_class' => 'main-nav',
'fallback_cb' => 'responsive_fallback_menu',
'theme_location' => 'header-menu')
);
?>

<?php if (has_nav_menu('sub-header-menu', 'responsive')) { ?>
<?php wp_nav_menu(array(
'container' => '',
'menu_class' => 'sub-header-menu',
'theme_location' => 'sub-header-menu')
);
?>
<?php } ?>

<?php responsive_header_bottom(); // after header content hook ?>

</div><!-- end of #header -->
<?php responsive_header_end(); // after header container hook ?>

<?php responsive_wrapper(); // before wrapper container hook ?>
<div id="wrapper" class="clearfix">
<?php responsive_wrapper_top(); // before wrapper content hook ?>
<?php responsive_in_wrapper(); // wrapper hook ?>

最佳答案

你可以用css实现这个

thead {position:fixed; top:0px;}

检查这个链接

http://jsfiddle.net/john_rock/h6hfX/1/

关于php - 向下滚动时如何停止页面顶部的导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17947102/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com