如何将不同的样式应用于Wordpress wp_nav_menu()

发布于 2024-09-19 04:02:33 字数 639 浏览 2 评论 0原文

我正在使用Wordpress 3.0。是否可以将不同的样式类应用于wordpress wp_nav_menu()? 目前我有五页,我想按以下顺序申请。

<ul>
      <h2>
        <li><a href="#">Example1</a> </li>
      </h2>
      <span>
      <li><a href="#">Example2</a></li>
      </span>
      <h4>
        <li><a href="#">Example3</a></li>
      </h4>
      <h3>
        <li><a href="#">Example4</a></li>
      </h3>
      <h5>
        <li><a href="#">Example5</a></li>
      </h5>
</ul>

I am using Wordpress 3.0.Is it possible to apply different style class to wordpress wp_nav_menu()?
Currently five pages for me and I would like to apply in following order.

<ul>
      <h2>
        <li><a href="#">Example1</a> </li>
      </h2>
      <span>
      <li><a href="#">Example2</a></li>
      </span>
      <h4>
        <li><a href="#">Example3</a></li>
      </h4>
      <h3>
        <li><a href="#">Example4</a></li>
      </h3>
      <h5>
        <li><a href="#">Example5</a></li>
      </h5>
</ul>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜深人未静 2024-09-26 04:02:33

这在语义上不是正确的 html - 也许您想向每个 li 添加一个类?

WP 将类添加到其生成的 LI 中,如下所示:

page_item page-item-27

其中数字与文章/页面的 ID 相关。

CSS:

.page-items-27 {
    color:#fff;
    background:blue;
    font-size:14px;
    // etc
}

that isn't semantically correct html - perhaps you want to add a class to each li instead?

WP adds classes to its generated LIs like so:

page_item page-item-27

where the number is related to the ID of the article/page.

css:

.page-items-27 {
    color:#fff;
    background:blue;
    font-size:14px;
    // etc
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文