WordPress:如何为导航菜单分配不同的颜色
我想给我的顶部导航菜单按钮单独的颜色。例如,我希望“主页”菜单按钮的颜色与“关于”菜单按钮的颜色不同。有人可以帮我解决这个问题吗?我的 CSS 很糟糕。
有没有 WordPress 插件可以做到这一点。
我希望有人帮助我。提前致谢。
托马斯
I would like to give my top navigation menu buttons separate colors. For instance, I want the "Home" menu button to have a different color from that of the "About" menu button. Could anyone please assist me with this. My CSS is terrible.
Is there any WordPress plugin that does this.
I hope somebody helps me out. Thanks in advance.
Tomas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用 Wordpress 菜单管理,您可以通过“外观”下的“菜单”选项为每个菜单项分配一个类,您只需创建多个具有所需颜色的 css 类,然后单击菜单项上的下拉菜单并添加它。
If you're using Wordpress menu management you can assign a class to every menu item through the "Menus" option under "Appearance", you just have to create multiple css classes with the desired colors and click the drop-down on the menu item and add it.
首先,您知道如何打开 style.css(或适合您主题的任何主 CSS 文件)。打开后,为您想要更改的任意多个菜单项添加跨度类。例如:
然后,打开 page.php(或任何主 PHP 文件)并将这些 CSS span 类包装在菜单项的 html 周围。然后,您当然可以添加一些简单的 :hover 效果来更改鼠标滚动时的颜色。只需在 CSS 文件中重新输入 CSS 项并在其后添加 :hover 即可。例如:
那么,好了!希望能有所帮助。如果您从核心构建网站,它总是会更有趣,并且您可以更好地控制周围的事物。如果您对此有任何疑问,请告诉我。
First, do you know how to open the style.css (or whatever the main CSS file is for your theme). Once open, add span classes for however many menus items you want to change. For example:
Then, open your page.php (or whatever the main PHP file is) and wrap these CSS span classes around the html for the menu items. Then, you can of course add some simple :hover effects to change the color when the mouse scrolls over. Just retype the CSS item in the CSS file and add :hover after it. For example:
So, there ya go! Hope that helps a bit. It's always more fun and you have better control of what's around you if you build a site from the core. Lemme know if you have any questions on that.
为什么不使用 X:nth-child(n) 选择器。
只需将“n”替换为元素的位置,然后将您想要选择的元素类型替换为 X。
Why not use X:nth-child(n) selector.
Just replace "n" with the position of the element and put the type of element you wanna select in place of X.