响应式网页设计,移动检测穿插,以实现更好的控制(Responsive web design with mobile detection interspersed for greater control

编程入门 行业动态 更新时间:2024-10-28 15:20:50
响应式网页设计,移动检测穿插,以实现更好的控制(Responsive web design with mobile detection interspersed for greater control)

我刚刚完成了我的第一个网站,其中考虑了移动优先的响应式设计流程。 该网站在移动设备上看起来很棒,但是桌面体验非常缺乏。 在不影响移动体验的情况下,我没有什么好办法可以改善桌面体验,即使这样,我也有一些使用纯客户端方法无法做到的事情。

我不想管理两个单独的网站(移动,桌面)。 我想要做的是让移动检测服务器端更多地控制何时加载/显示更多数据等。

我想做类似的事情:

// in view ... if not request.mobile: related_posts = post.get_related_posts() ... // in template ... {% if not request.mobile and related_posts %} {{ related_post_stream(related_posts) }} {% endif %} ...

令人惊讶的是,我没有看到很多关于以这种方式做事的在线讨论。 我读过的大多数文章要么推荐纯粹的(移动优先)响应式设计,要么推荐单独的移动网站,尽管这看起来不错。 这样做有不利之处吗?

I have just finished building my first website with a mobile-first responsive design process in mind. The site looks and works great on mobile devices, but the desktop experience is quite lacking. There's no good way I can improve the desktop experience without compromising the mobile experience, and even then there are just some things I can't do using a pure client side approach.

I don't want to have to manage two separate websites (mobile, desktop). What I want to do is have mobile detection server side to have more control of when I load/display more data, etc.

I want to do something akin to:

// in view ... if not request.mobile: related_posts = post.get_related_posts() ... // in template ... {% if not request.mobile and related_posts %} {{ related_post_stream(related_posts) }} {% endif %} ...

Surprisingly, I don't see much online discussion about doing things this way. Most articles I've read either recommend pure (mobile-first) responsive design or a separate mobile website, although this seems like a decent idea. Is there a downside to doing this?

最满意答案

如果你使用Django,有django-mobile模块,它允许你检查模板中的移动使用情况,如下所示:

{% if flavour != "mobile" %}Desktop version{% endif %}

如果您不使用Django,您仍然可以分析该模块的来源并为您的网站实现类似的功能。

If you are using Django, there is django-mobile module which allows you to check the mobile usage in the template like this:

{% if flavour != "mobile" %}Desktop version{% endif %}

If you are not using Django, you can still analyze the source of that module and implement something similar for your website.

更多推荐

本文发布于:2023-07-30 01:36:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1321448.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网页设计   web   design   mobile   Responsive

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!