简体   繁体   English

用JavaScript切换画布菜单是否是一种好习惯?

[英]Is an off-canvas menu with JavaScript toggle a good practice?

For my web-page I'm looking into implementing an off-canvas menu for small screen sizes. 对于我的网页,我正在考虑为小屏幕尺寸实现画布外菜单。 The frontend framework I'm using (UIKit) implements the toggling using JavaScript. 我正在使用的前端框架(UIKit)使用JavaScript实现了切换。

Is this considered good practice? 这被认为是好的做法吗? Or should I rather look into a solution solely based on CSS? 还是我应该只考虑基于CSS的解决方案? I have no idea how many people will have JavaScript disabled on their mobile devices (which is the use case for the off-canvas menu, it is not shown on larger screen sizes via CSS media queries) and thus could not toggle the menu. 我不知道有多少人会在他们的移动设备上禁用JavaScript(这是“画布”菜单的用例,它不会通过CSS媒体查询在较大的屏幕尺寸上显示),因此无法切换菜单。

I would go ahead and (I have) implement it and have a fallback. 我会继续并(实施)实施它并进行后备。 I've seen it done many times. 我已经看过很多次了。 There are plenty of examples of its usage, so I'd go ahead with your plan to implement it. 有很多使用它的示例,因此我将继续执行您的计划以实现它。

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

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