php - 使用自定义类在 wordpress 中创建下拉菜单

标签 php html css wordpress

我正在尝试创建一个下拉菜单,并在网上进行了广泛搜索,但没有成功。我已将自定义类添加到 wp_nav_menu 并尝试添加自定义 css,但我似乎无法使其工作。

这是我的header.php

 <div id="menu">
    <ul>
        <li id="access"><?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'dropdown', 'container_id' => 'menu-header', ) ); ?></li>
    </ul>
</div>

这是我的 style.css

.black-line{
    background-color: #000;
    width: 100%;
    height: 6px;
}

a:hover{
    text-decoration: none !important;
    color: #000 !important; 
}

#menu {
    width: 550px;
    height: 35px;
    font-size: 16px;
    text-align: center;
    border-radius: 8px;
    height: auto;
    padding: 8px 0px;
    margin: 0px;
    display: inline;
}

#menu li { 
display: inline; 
padding: 20px; 
margin:0 auto;
font-weight: bold;
}

.menu-item-28{
    background-color: #7ED321;
    border-radius: 13px;
}

ul li a{
    color:#000;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

footer{
    border-top: 1px solid #DBDBDB;
    margin-top:15px;
}

.coming{
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-weight: bold;
}

.spacing{
    padding-left: 9px;
    margin-right: 5px;
    margin-top: 10px;

}

.social-and-coming{
    margin-top: 10px;
}

p.coming{
    font-size: 15px;
}

.copy{
    padding-bottom: 15px;
}

.footer{
    margin-bottom: 10px; 
}

footer{
  margin-top: 29px;
}

我可能会覆盖我的 css 中的某些内容,这会阻止我创建一个内容。

这是我的 functions.php

function register_my_menus() {
  register_nav_menus(
    array(
       'primary' => __( 'Primary Menu', 'Creativeforces' ),
      'header-menu' => __( 'Header Menu' ),
      'extra-menu' => __( 'Extra Menu' )
    )
  );
}

add_action( 'init', 'register_my_menus' );

   $defaults = array(
    'default-image'          => '',
    'width'                  => 0,
    'height'                 => 0,
    'flex-height'            => false,
    'flex-width'             => false,
    'uploads'                => false,
    'random-default'         => false,
    'header-text'            => true,
    'default-text-color'     => '',
    'wp-head-callback'       => '',
    'admin-head-callback'    => '',
    'admin-preview-callback' => '',
);
add_theme_support( 'custom-header', $defaults );

任何帮助将不胜感激!我试过使用插件,但似乎没有任何效果!

最佳答案

您是否特别需要使用 wordpress?您也可以使用 CSS 执行此操作,这可能会更容易。

关于php - 使用自定义类在 wordpress 中创建下拉菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35778709/

相关文章:

php - 仅在没有引用时引用复合键的一个字段和 'ON DELETE CASCADE'

php - mysql_connect() 导致页面不显示(WAMP)

javascript - 使提交 <button> 在 <form> block 之外工作?

java - 在 JSP Eclipse 中禁用格式化程序

javascript - Body 中的 HTML 代码

php - linux下编辑PHP ini文件问题

php - 如何使用 php 为 sql 服务器设置 2d Json 数组?

html - 什么时候应该清除 float 的 HTML 元素?

css - 链接在点击时移动,这是我见过的最奇怪的事情(在 CSS 中)

CSS超链接样式