CSS 菜单与 JavaScript 菜单
在制作下拉菜单时,有像 superfish 这样的 jQuery 菜单和纯 CSS 菜单。 JS 菜单和 CSS 菜单有什么区别吗?
我不需要 onclick
事件来覆盖默认锚点。我只需要能够单击菜单项,然后按照 ...
转到另一个页面。
In making a drop down menu, there are jQuery menus like superfish and pure CSS menus. Is there any difference between JS menus and CSS menus?
I don't need onclick
event to overwrite the default anchor. I just need to be able to click the menu item then follow the <a href="...">...</a>
to another page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
区别:
Differences:
从哲学的角度来看,CSS 实际上是关于样式的,JS 是关于交互的。然而,现在 WebKit 已经全力支持 CSS 转换,这条界限已经变得相当模糊了。
最后,尽可能多地使用 CSS,然后添加 JavaScript 来提高交互的水平是很棒的。诸如键盘导航之类的东西...允许鼠标从一个链接移动到下一个链接的微妙延迟...动画等。
From a philosophical standpoint, CSS is really about styling, JS about interaction. However, now that WebKit has gone full-throttle with CSS transitions, that line has blurred quite a bit.
In the end, it's great to use CSS as much as you can, then add JavaScript for that added level of polished interaction. Things like keyboard navigation...subtle delays to allow a mouse to travel from one link to the next...animations, etc.
即使我是一名开发人员,我也总是尽量避免编程。
我想我会使用 CSS 菜单,该菜单将使用 onHover 事件显示下拉菜单 DIV。
JavaScript 可能会受到其他应用程序的影响,可能会重复变量。并且可以轻松移植到通常不支持JS的移动设备上
Even thought I am a developer, I always try to avoid programming at all.
I think I will go with a CSS menu that will show the drop menu DIV using the onHover event.
JavaScript could be influenced by other apps, maybe duplicating variables. And you can port it easily to mobile devices that usually don't support JS
一个明显的区别是 JS 菜单的可定制性更高。仅使用 CSS 无法控制诸如菜单显示速度之类的事情。
An obvious difference is that JS menus are a lot more customizable. You can't control things like how fast a menu appears using just CSS.