CSS菜单vs JavaScript菜单 [英] CSS menu vs JavaScript menu

查看:115
本文介绍了CSS菜单vs JavaScript菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在制作下拉菜单时,有jQuery菜单,如superfish和纯CSS菜单。 JS菜单和CSS菜单之间有什么区别吗?

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?

我不需要 onclick 事件来覆盖默认锚点。我只需要能够点击菜单项,然后按照< a href =...> ...< / a>

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.

推荐答案

区别:


  1. 如果用户已禁用JavaScript,JavaScript分解;如果用户已禁用CSS(这种情况较少见),CSS菜单将无法正常运行

  2. 通过jQuery等库创建的JavaScript更为跨浏览器,因为跨浏览器问题由图书馆处理

  3. JavaScript菜单更灵活,因为CSS仍然不够成熟,无法创建高度复杂的效果(不要忘记JavaScript是一种编程语言,而编程语言意味着但是CSS更像是声明式

  4. CSS菜单的尺寸通常较小(见思考结果),但这不是一个很大的问题在今天的互联网速度用户有。

  5. 有时在菜单中,您需要分组,这是无法通过CSS实现的,但可以在JavaScript中完成。 (分组意味着您希望在点击某个项目时打开一个下拉列表,而不是按照链接地址)。

  1. JavaScript break down if user has disabled JavaScript; CSS menus won't work if user has disabled CSS (which is less common)
  2. JavaScript made via libraries like jQuery are more cross-browser, due to the fact that cross-browser issues are handled by library
  3. JavaScript menus are more flexible, as CSS still is not enough mature for creating highly complicated effects (don't forget that JavaScript is a programming language, and a programming language means that you can do almost anything you want. But CSS is more like declarative fashioned)
  4. CSS menus are usually lighter in size (see Thought Results for example), but this is not a big deal in today's Internet speeds users have.
  5. Sometimes in a menu, you need grouping, which is not achievable via CSS, but can be done in JavaScript. (grouping means that you want to open a drop down on click of an item, not following the link address. Of course, in your case, this is not a requirement)

这篇关于CSS菜单vs JavaScript菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆