通过 CSS 定制 drupal 菜单?
我一直在相当成功地摆弄 drupal 主题(或者至少,我是这么认为的),但是当我尝试将 css 编码注入主链接菜单以自定义它(就像我通常通过 html+css 所做的那样)时,我点击了墙。
我已经能够将 css 样式应用于 div、链接和文本,但我想更多地自定义主要(和辅助)链接菜单,也许使用一些 css sprite 菜单技术,但同时保持 drupal 兼容并使用尽可能多的内容drupal自己的php在这个过程中。或者如果我真的必须重写一些代码,我不介意,尽管我还不是程序员。
我浏览过几个网站,但没有任何特别有用的东西,所以如果有人能指出我正确的方向,我将非常感激。
提前致谢。
I've been fiddling around with drupal theming quite succesfully (or at least, that's what i think), but when I tried to inject css coding to the primary links menu to customize it as i generally do via html+css, i hit a wall.
I have been able to apply css styles to divs, links and text, but I would like to customize the primary (and secondary) links menus much more, perhaps with some css sprite menu techniques, but while remaining drupal-compliant and using as much of drupal's own php in the process. or if i really have to rewrite some code, i don't mind, though i am not quite the programmer yet.
i have been around several sites but i haven't anything particularly useful, so if anyone can point me to the right direction, i will be quite grateful.
thanx in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以为每个菜单项添加一个类似 id 的类 - 在 template.php 中添加此函数
此代码可以更清晰,但我添加了更多行,以便您可以更好地阅读它。
You can add a id-like class for each menu item - add this function in your template.php
This code can be cleaner, but i've added more lines so you can read it better.
如果我正确理解你的问题,你会想在你的菜单中添加一个自定义类/id。这可以通过覆盖给定菜单的 theme_menu_tree 来完成。我通过将以下内容添加到我的 template.php 文件中来为我的主菜单执行此操作:
希望这会有所帮助。
您还应该查看 themer 模块,它为您提供有关模板功能等的建议。
干杯,
约尔根
if I understand your question correctly you will like to add a custom class/id to you menu . This can be done by overriding the theme_menu_tree for a given menu. I do this for my main menu by adding the following to my template.php file:
hope this helps.
You should also have a look at the themer module, which gives you suggestion for template functions and more.
cheers,
Jørgen