[英]Moving the “active” class in a dropdown menu to the users current page
So i thought i would give the Foundation framework a go and the first problem i run into is class="active" in a dropdown menu. 因此,我认为我可以继续使用Foundation框架,并且遇到的第一个问题是下拉菜单中的class =“ active”。
What i want is the class to apply to the page link (in the dropdown list) the user is currently viewing, if this is easily done any help would be appreciated. 我想要的是将类应用于用户当前正在查看的页面链接(在下拉列表中),如果可以轻松完成此操作,将不胜感激。
I have scoured the Foundation Docs and the world wide web and gotten nowhere unfortunately. 我已经搜寻了基金会文档和万维网,但不幸的是没有找到任何地方。
What you are tying to achieve is usually done by the backend or my your front-end MVC (like angular or backbone) by testing where you are and printing an 'active' class on the right link. 您想要实现的目标通常是通过后端或您的前端MVC(例如,角度或骨干)通过测试您所在的位置并在正确的链接上打印“活动”类来完成的。
Foundation isn't an MVC framework. Foundation不是MVC框架。 It simply helps quickly developing some HTML, CSS, and JavaScript by leveraging their modular, pre made code.
它仅通过利用它们的模块化,预制代码来帮助快速开发一些HTML,CSS和JavaScript。
That being said, if you wanted to achieve this purely on the front-end, you would need to create a function that parses your URL, finds the link with that matching URL, and add a class of 'active' on the matched on. 话虽如此,如果您仅想在前端实现此功能,就需要创建一个函数来解析您的URL,找到具有该匹配URL的链接,并在匹配的on上添加一个“ active”类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.