简体   繁体   English

如何将桌面网站的导航转换为可折叠菜单?

[英]How can I convert a desktop site's navigation into a collapsable menu?

The header has a navigation menu I'd prefer to keep, but it's taking up too much space. 标题有一个我宁愿保留的导航菜单,但它占用了太多的空间。 What can I do to make it look good on mobile? 我该怎么做才能让它在移动设备上看起来很棒?

One possibility is to use togglers - buttons that make its inner content appear/disappear. 一种可能性是使用切换器 - 使其内部内容出现/消失的按钮。 The uraniumjs library contains some widgets, one of them being a very simple yet useful toggler implementation . uraniumjs库包含一些小部件,其中一个小部件是一个非常简单但有用的切换器实现 It also does that unobtrusively. 它也是不引人注目的。

You will need to include the uranium js file, so you can just use it. 您需要包含铀js文件,以便您可以使用它。 Then, you can do it as explained below. 然后,您可以按照以下说明执行此操作。

You need to transform your menu code into three parts: a wrapper container, a "button" section and a content section. 您需要将菜单代码转换为三个部分:包装容器,“按钮”部分和内容部分。 To identify each of those parts, use these data attributes: 要识别每个部分,请使用以下数据属性:

data-ur-set="toggler"

(add this attribute to the wrapper) (将此属性添加到包装器)

data-ur-toggler-component="button"

(add this attribute to the "button" section) (将此属性添加到“按钮”部分)

data-ur-toggler-component="content"

(add this attribute to the content section) (将此属性添加到内容部分)

You need to include these CSS rules somewhere too: 您还需要在某处包含这些CSS规则:

*[data-ur-set='toggler'] *[data-ur-toggler-component='content'] {
  display:none;
}
*[data-ur-set='toggler'] *[data-ur-toggler-component='content'][data-ur-state='enabled'] {
  display: block;
}

You can see a small example running here: http://play.tritium.io/8af1576e385f5db05f6dc75404f993c16485395b . 你可以在这里看到一个小例子: http//play.tritium.io/8af1576e385f5db05f6dc75404f993c16485395b

Both the Bloomingdales and the Macys mobile sites use that approach. BloomingdalesMacys移动网站都使用这种方法。 You can see it working there. 你可以看到它在那里工作。

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

相关问题 如何使我的移动网站文本大小显示为与我的桌面网站相同的大小? - How can I make my mobile site text size appear the same size as my desktop site? 如何使菜单按钮在移动wordpress网站上可见? - How can I make the menu button visible on mobile wordpress site? 如何让我的嵌套导航菜单在移动设备上工作? - How can I make my nested navigation menu work on mobile? 如何使用JavaScript将桌面用户重定向到一个站点并将移动用户重定向到另一个站点 - How can I redirect Desktop Users to one site and Mobile Users to another with JavaScript Chrome的“请求桌面版网站”选项如何运作? - How does Chrome's “Request Desktop Site” option work? 导航菜单显示在桌面但不显示在移动视图中 - Navigation menu show in desktop but not show in mobile view 我的桌面如何访问自动重定向的移动网站? - How can my desktop visit a mobile site that automatically redirects? 如何在移动网站上创建“查看桌面版本”链接,而在解析后又不会循环回到移动版本? - How can I create a “view to desktop version” link on mobile site without it looping back to mobile version when it resolves? 如何强制Bootstrap 3使用桌面菜单? - How do I force Bootstrap 3 to use the desktop menu? 移动网站-如何创建Cookie,以记住“切换到桌面”网站 - Mobile Site - How Do I Create a Cookie which remembers “Switch to Desktop” Site
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM