简体   繁体   English

纯CSS下拉菜单

[英]Pure CSS Dropdown Menu

I have been working on facebook application and you know on facebook native javascript is not allowed, they have their own implementation FBJS which is troublesome when it comes to creating stuff like menus. 我一直在研究Facebook应用程序,您知道在Facebook上不允许使用本机javascript,它们有自己的实现FBJS,在创建菜单之类的内容时会遇到麻烦。

Is there any pure CSS dropdown solution without any involvement of javascript (javascript is used in all the solutions i have seen to tackle IE6)? 是否有没有JavaScript参与的纯CSS下拉解决方案 (我见过的所有解决IE6的解决方案都使用javascript)?

Yes, there are many approches. 是的,有很多方法。 Have a look at Listamatic . 看看Listamatic

Can you take a simple list and use different Cascading Style Sheets to create radically different list options? 您可以采用简单的列表并使用不同的层叠样式表来创建根本不同的列表选项吗? The Listamatic shows the power of CSS when applied to one simple list. Listamatic展示了将CSS应用于一个简单列表时的功能。

There are both vertical and hortizonal menus, using pure CSS. 垂直菜单和水平菜单都使用纯CSS。

Some working examples: 一些工作示例:

  1. http://www.xs4all.nl/~peterned/examples/cssmenu.html http://www.xs4all.nl/~peterned/examples/cssmenu.html
  2. http://www.tjkdesign.com/articles/dropdown/demo.asp http://www.tjkdesign.com/articles/dropdown/demo.asp

Actually, you can implement a basic list with few lines: 实际上,您可以用几行实现一个基本列表:

li ul { display: none; } 
li:hover > ul { display: block; }

Note that you need JavaScript if you support IE6 (as it does'nt work with li:hover). 请注意,如果您支持IE6,则需要JavaScript(因为它不适用于li:hover)。

Google recently began phasing out IE6 support and notified their apps for domain customers to upgrade their users. Google最近开始逐步淘汰IE6支持,并通知其应用程序供域客户升级其用户。 Unless you are serving a market or customer base that you know is using IE6 and is unable or unwilling to upgrade I'd just ignore it and use the :hover solution sans javascript. 除非您服务的市场或客户群是已知正在使用IE6并且无法或不愿升级的产品,否则我将忽略它并使用:hover解决方案(不使用JavaScript)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM