What was the thinking behind the implementation of the dropdown menu in Twitter Bootstrap?

﹥>﹥吖頭↗ 提交于 2019-12-03 09:11:00

问题


I've been looking at Twitter's Bootstrap framework and I'm really impressed. However, I don't understand the thinking behind the way the dropdown navigation menu works.

Firstly, in order to see child links, you have to click on the parent. I can see the benefits of this, but why not have the more traditional dropdown on hover approach as the default?

Secondly, it seems that the thinking behind the Twitter Bootstrap's dropdown menu illuminates parent pages. I'm probably not explaining that very well... Say, you have a simple web page structure:

  • Home
  • About
    • The Team
  • Services
    • Web Design
    • Hosting
    • Domains
  • Contact

In a traditional dropdown menu structure, you'd hover over "about" and "services" and the dropdown menu containing the child links (eg "Web design", "Hosting" etc.) would appear. However, you would also be able to click on the parent page (i.e. "About" and "Services") and visit them.

With Bootstrap you can't have a parent page in the structure, you have to use the anchor tag ("#"). When you click this, you then see the pages in the dropdown. This is no good if there is a parent page. It's also not great from a semantic (what does "#" mean?) and accessibility (javascript turned off, screen readers etc) point of view.

I've probably missed something, but can someone explain the thinking behind this particularly in regards to parent pages and semantic html/accessibility?


回答1:


It has been done this way simply because hover menus do not work well on touch screen devices.

https://github.com/twitter/bootstrap/issues/1029




回答2:


Mark Otto (@mdo), one of the main developers of Bootstrap, answered on his blog:

http://www.markdotto.com/2012/02/27/bootstrap-explained-dropdowns/




回答3:


There are many CSS and js hacks out there for this functionality, but all of them is breaking something.

I am against using hover, but if someone really needs that, then do it properly. I made a plugin which is using only the Bootstrap javascript API without any hack, so it works on all devices, without braking the usability:

https://github.com/istvan-ujjmeszaros/bootstrap-dropdown-hover




回答4:


The design decision was done by the folks at Twitter see http://markdotto.com/2012/02/27/bootstrap-explained-dropdowns/

If you look at the number of people that look for a solution to get hover back (some 1000 positive/ some 700000 fews as of 2017-11):

How to make Twitter Bootstrap menu dropdown on hover rather than click

you can see that the decision is not making everybody happy. Especially if you migrate web pages that have had hover menus for many years it's awkward to be "forced" to a new style by some framework.



来源:https://stackoverflow.com/questions/9433285/what-was-the-thinking-behind-the-implementation-of-the-dropdown-menu-in-twitter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!