我需要一个网站模型,其中包含一个使用bootstrap响应的菜单。
你可以帮我举个例子吗?
我尝试了几种变体,但我意识到我必须这样做才能使这个网站成为一个菜单
www.dg-design.ch
先谢谢!
答案 0 :(得分:1)
HTML:
<header id="masthead" class="site-header" role="banner">
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="row">
<div class="site-navigation-inner col-sm-12">
<div class="navbar-header">
<button type="button" class="btn navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<?php if( get_header_image() != '' ) : ?>
<div id="logo">
<a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php header_image(); ?>" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" 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 class="navbar-brand" href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span>
</div><!-- end of #logo -->
<?php endif; // header image was removed (again) ?>
</div>
<?php sparkling_header_menu(); ?> // <--The issue is here call to your menu instead
</div>
</div>
</div>
</nav><!-- .site-navigation -->
</header><!-- #masthead -->
CSS:
/* Clearing floats */
.clear:before,
.clear:after,
.site-header:before,
.site-header:after,
.site-content:before,
.site-content:after,
.site-footer:before,
.site-footer:after,
.home-widget-area:before {
content: '';
display: table;
}
.clear:after,
.site-header:after {
clear: both;
}
/* =Navigation
----------------------------------------------- */
.site-content [class*="navigation"] a {
border: 1px solid #DADADA;
background-color: #fff;
padding: 8px 14px;
font-size: 12px;
border-radius: 4px;
display: block;
margin: 0 0 1.5em;
overflow: hidden;
}
.paging-navigation {
text-transform: uppercase;
}
.site-content [class*="navigation"] a:hover {
color: #fff;
background: #DA4453;
text-decoration: none;
}
.more-link {
float: right;
margin: 10px 0;
}
.single .nav-links {
margin-top: 30px;
}
[class*="navigation"] .nav-previous {
float: left;
}
[class*="navigation"] .nav-next {
float: right;
text-align: right;
}
.nav>li>a {
text-transform: uppercase;
}
.navbar.navbar-default {
background-color: #363636;
font-family: 'Open Sans', serif;
margin-bottom: 0;
font-weight: 500;
}
.navbar-default .navbar-nav > li > a {
color: #F5F7FA;
line-height: 40px;
text-transform: uppercase;
font-size: 12px;
}
.navbar > .container .navbar-brand {
color: #DADADA;
font-size: 20px;
margin: 13px 0;
font-family: 'Roboto Slab', serif;
}
.navbar-default .navbar-nav > .open > a,
.navbar-default .navbar-nav > .open > a:hover,
.navbar-default .navbar-nav > .open > a:focus {
border-right: none;
border-left: none;
}
.navbar {
border-radius: 0;
}
.navbar-default {
border: none;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus,
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus,
.navbar-default .navbar-nav > .open > a,
.navbar-default .navbar-nav > .open > a:hover,
.navbar-default .navbar-nav > .open > a:focus {
color: #DA4453;
background-color: transparent;
}
.dropdown-menu > li > a:hover,
.dropdown-menu > li > a:focus,
.navbar-default .navbar-nav .open .dropdown-menu > li > a:hover,
.navbar-default .navbar-nav .open .dropdown-menu > li > a:focus {
color: #fff;
background-color: #DA4453;
}
.dropdown-menu {
font-size: 13px;
}
.navbar-default .navbar-nav .open .dropdown-menu > li > a {
color: #656D78;
}
@media (max-width: 767px) {
.navbar-default .navbar-nav .open .dropdown-menu > li > a {
color: #DADADA;
}
}
.nav .open > a, .nav .open > a:hover, .nav .open > a:focus {
border-left: 1px solid rgba(0, 0, 0, 0.1);
}
@media (min-width: 767px) {
ul.nav li.dropdown:hover > ul.dropdown-menu {
display: block;
}
}
.dropdown-menu > li > a {
padding: 10px 15px;
color: #636467;
}
.dropdown-menu,
.dropdown-menu > .active > a,
.dropdown-menu > .active > a:hover,
.dropdown-menu > .active > a:focus {
border: none;
}
.dropdown-menu>.active>a,
.dropdown-menu>.active>a:hover,
.dropdown-menu>.active>a:focus {
background-color: #DA4453;
color: #fff;
}
.dropdown-menu .divider {
background-color: rgba(0, 0, 0, 0.1);
}
.navbar-nav > li > .dropdown-menu {
padding: 0;
}
.navbar-nav > li > a {
padding-top: 18px;
padding-bottom: 18px;
}
.navbar-default .navbar-toggle:hover,
.navbar-default .navbar-toggle:focus {
background-color: transparent;
}
.nav.navbar-nav {
float: right;
}
@media (max-width: 767px) {
.nav.navbar-nav {
float: none;
}
.navbar > .container .navbar-brand {
margin: 0;
}
.navbar-default .navbar-nav > li > a {
line-height: 20px;
padding-top: 10px;
padding-bottom: 10px;
}
}
更改1
想出来:你需要一个名为Navwalker的插件,函数调用它来支持wpBootstrap Navbars下面是代码的链接和调用函数来让你运行:
PHP
<?php
/**
* Load custom nav walker
*/
require get_template_directory() . '/inc/navwalker.php';
?>
以下是Navwalker.php的链接:
GitHub URI:https://github.com/twittem/wp-bootstrap-navwalker
只需将其添加到您的wp-content =&gt; themes =&gt; &LT;你的主题&gt; =&GT; inc =&gt; navwaker.php
更改3 也: 将以下代码更改为您对header_menu的调用 发件人:强>
<?php
...
sparkling_header_menu();
...
?>
要强>
<?php
wp_nav_menu( array( 'theme_location' => 'primary' ) );
?>
试一下,看看它是否有效!!让我知道如果没有,我会解决它
快乐编码!!
下载Sparkling WP主题答案 1 :(得分:1)
如果您要将bootstrap html转换为wordpress模板,请使用此navwalker作为菜单 https://github.com/twittem/wp-bootstrap-navwalker