我正在尝试开发一个带有粘性导航栏的主题,但问题是wordpress的管理栏覆盖了我的粘性导航栏,它是使用bootstrap制作的。请帮忙。这是我的导航条形码:
<!-- Fixed navbar -->
<nav class="navbar navbar-custom navbar-fixed-top" id="nav-nav">
<div class="container">
<a class="navbar-brand" href="#"><?php bloginfo(\'name\');?> </a>
<div id="menu" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<?php
wp_nav_menu( array(
\'menu\' => \'primary\',
\'theme_location\' => \'primary\',
\'depth\' => 2,
\'container\' => \'div\',
\'container_class\' => \'collapse navbar-collapse\',
\'container_id\' => \'bs-example-navbar-collapse-1\',
\'menu_class\' => \'nav navbar-nav\',
\'fallback_cb\' => \'WP_Bootstrap_Navwalker::fallback\',
\'walker\' => new WP_Bootstrap_Navwalker())
);
?>
</ul>
<!-- search form-->
<i class="fa fa-search search-top"></i>
<div class="search-form-top">
<?php get_search_form(); ?>
</div>
</div><!--/.nav-collapse -->
</div>
</nav>
最合适的回答,由SO网友:Chandra Kumar 整理而成
您可以使用加载项尝试此代码functions.php
当前主题的文件:
add_action(\'wp_head\', \'my_wp_head\');
function my_wp_head(){
echo \'<style>\'
.PHP_EOL
.\'body{ padding-top: 70px !important; }\'
.PHP_EOL
.\'body.body-logged-in .navbar-fixed-top{ top: 46px !important; }\'
.PHP_EOL
.\'body.logged-in .navbar-fixed-top{ top: 46px !important; }\'
.PHP_EOL
.\'@media only screen and (min-width: 783px) {\'
.PHP_EOL
.\'body{ padding-top: 70px !important; }\'
.PHP_EOL
.\'body.body-logged-in .navbar-fixed-top{ top: 28px !important; }\'
.PHP_EOL
.\'body.logged-in .navbar-fixed-top{ top: 28px !important; }\'
.PHP_EOL
.\'}</style>\'
.PHP_EOL;
}