html导航菜单到wordpress

时间:2014-11-13 04:35:47

标签: html wordpress

我需要你的帮助我在我的html中有导航菜单我想把它转移到Wordpress时准确得到它们但是当我将我的html转移到Wordpress时它看起来并不相同。 Wordpress无法读取我的Navbar菜单CSS,为什么会这样?你能帮助我吗? 请注意我想说的内容。

HTML file

HTML to Wordpress

这是我的导航菜单html代码和css:



/* navbar*/
.navbar-default {
   /* navbar  background-color: #F8F8F8;
    background:url(../images/header-bg.png);*/

    background: #16ad99; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzE2YWQ5OSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM4NWUyZDAiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(left,  #16ad99 0%, #85e2d0 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#16ad99), color-stop(100%,#85e2d0)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left,  #16ad99 0%,#85e2d0 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left,  #16ad99 0%,#85e2d0 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left,  #16ad99 0%,#85e2d0 100%); /* IE10+ */
background: linear-gradient(to right,  #16ad99 0%,#85e2d0 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#16ad99', endColorstr='#85e2d0',GradientType=1 ); /* IE6-8 */


    border-color: #93BBEB;
}

/* removing white space between navbar and image below*/
.navbar{
	margin-bottom:0px;

}/* end */



/*===================
   NAV BAR
  ===================*/
 .nav .navbar-nav{
 	display:inline;

 }
.nav .navbar-nav > li > a {
    color: #ffffff;
}

.nav .navbar-nav > li > a:hover,
.nav .navbar-nav > li > a:focus {
    color: #000000;
}

/* link */
.navbar-default .navbar-nav > li > a {
    color: #ffffff;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
    color: #000000;
}



.navbar-default .navbar-nav > .active > a {
	color: #00A36E;

<!-- Static Top navbar -->
  		<header class="main-header">
	    <div class="navbar navbar-default navbar-static-top" role="navigation">
	      <div class="container">
	        <div class="navbar-header">
	          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".collapse">
	            <span class="sr-only">Toggle navigation</span>
	            <span class="icon-bar"></span>
	            <span class="icon-bar"></span>
	            <span class="icon-bar"></span>
	          </button>
	         
	        </div><!--END NAVHEADER-->

	        <div class="navbar-collapse collapse">
	          <?php
	          	wp_nav_menu(array
	          		(
	          		 'theme_location' => 'main-menu',
	          		 'container' => '',
	          		 'menu_class' => 'nav navbar-nav'	

		          		)

		          	);

	          ?>

	        </div><!--/.nav-collapse -->
	      
	      </div><!--END CONTAINER-->
	    </div><!--END NAVBAR-->
	    </header>
&#13;
&#13;
&#13;

&#13;
&#13;
<!-- Static Top navbar -->
  		<div class="navbar navbar-default navbar-static-top" role="navigation">
	      <div class="container">
	        <div class="navbar-header">
	          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".collapse">
	            <span class="sr-only">Toggle navigation</span>
	            <span class="icon-bar"></span>
	            <span class="icon-bar"></span>
	            <span class="icon-bar"></span>
	          </button>
	         
	        </div><!--END NAVHEADER-->

	        <div class="navbar-collapse collapse">
	          <ul class="nav navbar-nav">
	            <li><a href="index.html"><span class="glyphicon glyphicon-home"></span> Home</a></li>
	            <li><a href="Portfolio.html"><span class="glyphicon glyphicon-book"></span> Portfolio</a></li>
	            <li><a href="Contact.php"><span class="glyphicon glyphicon-envelope"></span> Contact</a></li>
	            
	          </ul>

	        </div><!--/.nav-collapse -->
	      
	      </div><!--END CONTAINER-->
	    </div><!--END NAVBAR-->
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

这个漂亮的小PHP脚本对我来说很棒。特别是因为你看起来像是在使用Bootstrap!这将获取您的页面并将其发布到具有下拉功能的BS菜单中。

LINK

将此功能添加到functions.php文件中:

// Register Custom Navigation Walker
     require_once('wp_bootstrap_navwalker.php');
// Nav Walker
     register_nav_menus( array(
     'primary' => __( 'Primary Menu', 'THEMENAME' ),
     ) );

然后你必须安装一个名为wp_bootstrap_navwalker.php的php文件(包含在我链接的网站上)

然后在header.php中输入以下内容:

<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
    </div>
    <div class="collapse navbar-collapse navbar-ex1-collapse">
       <?php 
            wp_nav_menu( array(
                'menu'              => 'primary',
                'theme_location'    => 'primary',
                'depth'             => 2,
                'container'         => '',
                'container_class'   => '',
                'menu_class'        => 'nav navbar-nav',
                'fallback_cb'       => 'wp_bootstrap_navwalker::fallback',
                'walker'            => new wp_bootstrap_navwalker())
                );
        ?>

                        <form role="form" method="get" id="searchform" action="<?php echo home_url() ; ?>/">
                            <div class="col-sm-2 input-group">
                                <input type="text" class="form-control" placeholder="Search" value="<?php echo esc_html($s, 1); ?>" name="s" id="s" maxlength="33" />
                                    <span class="input-group-btn">
                                        <button class="btn btn-search" id="searchsubmit" type="submit"><i class="fa fa-search"></i></button>
                                    </span>
                            </div>
                        </form>

    </div><!--/.nav-collapse -->
</div>

并使用&#34;菜单&#34;在WP版本的仪表板中,您可以创建一个菜单并将页面应用到该页面。真正易于使用且可扩展性很强。

试一试!

答案 1 :(得分:-1)

这很可能是因为您使用的是wp_nav_menu(),而您的原始代码与wp_nav_menu()生成的HTML不匹配。你可以发布原始代码和wordpress原始代码(生成的代码,而不是你输入到模板中的代码)