5 ms·
Wait, so sniffing on screen resolution is the way web developers distinguish desktops from mobile? That's just crazy. There should IMO be a preference sent, "I
by TeMPOraL 6y ago
Wait, so sniffing on screen resolution is the way web developers distinguish desktops from mobile? That's just crazy.
There should IMO be a preference sent, "I'm on a portable, touch-enabled device". I'm guessing it doesn't exist because it would add a bit to the fingerprint.
- jefftk 6y agoIn this case, "portable, touch enabled device" wouldn't match what we're talking about. Someone with a large tablet should receive the version optimized for larger screens. The website is saying "if your screen is at least this big, I'm going to show you the version for big screens". The OP has an unusual setup where their big screen is reporting as a smaller screen.
- masklinn 6y ago> Someone with a large tablet should receive the version optimized for larger screens. Not necessarily, because the “smaller screen” layout tends to be linked to the touch one e.g. larger active targets, while the “large screen” layout is optimised for precise pointing devices (mice) and may be nigh impossible to interact with using fingers.
- madeofpalk 6y agoWell, if you want to change for interactions, we have @media (pointer: coarse) and @media (pointer: fine) for that.
- bryanrasmussen 6y agothe way that web developers generally do responsive design is to use media queries checking the width of the screen they are on, as opposed to the device width. This is the suggested way because if you check the device width you know that they are on a small device and thus probably mobile but your styling changes for small windows (less wide windows) do not get applied, so 'best practice' is to check the actual screen width. Hardly anyone checks the height because for web development height is generally not that important. But this is often not useful because a lot of web solutions style things based on JavaScript and CSS and while the CSS will rerender automatically based on changing the screen size the JavaScript needs to detect you've changed the screen size and then rerender. So then there is a discussion as to how many people really resize the windows and do we need to catch this resize to do a rerender even though doing so is irritating and can be a resource hog (fixable by extra code but maybe better not to code at all!) But there are lots of other ways to detect if you are on a mobile device, you can detect if touch screen events are enabled etc. but then what if you have one of those weird desktops that became possible a few years ago (I nearly wrote popular instead of possible) where your laptop's monitor also has touch screen events. As a general rule it is best to do things based on the capacity of the system, and not by what type of system it is, but as the capabilities of our systems exist in infinite combinations it follows some things will just fall through no matter how exacting you try to be - maybe especially if you try to be too exacting.
- masklinn 6y ago> Wait, so sniffing on screen resolution is the way web developers distinguish desktops from mobile? There’s really no other information since “physical” dimensions are completely fake: a CSS inch is 96 CSS pixels which are “one pixel at 96 dpi at an arm’s length”.
- madeofpalk 6y agoScreen resolution is, more or less the best approach. Layouts need to fit a size, not a device, so that's why media queries based on the screen size are usually the best approach. If I resize my browser to make it smaller, I should get a layout to match that. If I'm using Safari on iPad, docked to the side of the screen, I should get a layout to match that. These are all about screen sizes, not "mobile vs desktop". For testing interaction cabailities, there are the @media (pointer: coarse) and @media (hover: hover) media queries for testing touch vs mouse, and hover capabilities, but it's important to not rely on these for mobile vs desktop layouts otherwise tomorrow a MS Surface user will post "Just because I have a touch screen, doesn't mean I'm on a phone".
- tuckerconnelly 6y agoBest practice dictates "mobile-first responsive design" with "progressive enhancements." So designing first for mobile and touchscreens seems ideal, and then adding special features for larger resolutions, and, in a separate media query, for devices with (hover: hover).
- donatj 6y agoThe general idea with well built responsive design is to build a site that works at any width, reflowing as things would break. You can try it by just resizing the window of most popular sites to be progressively smaller. It’s honestly been a significant improvement over dedicated mobile layouts and for the most part works pretty well.
- wruza 6y agoYes, they define a bunch of @media filters in css for different known screen widths. You usually get a surprising look when pointing out that it is crazy. “How else would you know that?” Something as simple as “use-case: handheld | bellyheld | desktop” property? Css designers missed this opportunity completely.
- robertoandred 6y ago“use-case: handheld | bellyheld | desktop” would give zero useful information. How would you detect a desktop with a small window?
- wruza 6y agoYou don’t, because you don’t know how far from that screen a user is. User can override default mode in a browser’s toolbar. That’s what OP wants but has instead to jump through dpi/font/scale hoops to achieve it. You may want to use desktop, tablet or mobile look that is not related to your device width.
- tootie 6y agoIt's a bad habit, but it's pretty common. Really, there's two distinct things to consider when building responsive design. One is viewport size (and really just width in most cases) and the other is touch vs mouse. Vertical monitors is one case, but so is touch-enabled monitors or mouse-enabled handhelds. Most of those are considered small enough edge cases, that it's not worth investing. Most websites look kinda crummy if you use a phone in landscape too. I used to insist that designers never say "phone, tablet, desktop" and instead say "small, medium and large" but it never stuck.
- matsemann 6y ago> Wait, so sniffing on screen resolution is the way web developers distinguish desktops from mobile? That's just crazy. No, it's not how it's done. And there is generally no logic trying to see if it's a mobile or not. One just have various designs for various sizes. When he has a 700px wide display, what else can the website do than collapse the content when it's not enough space for it?
- forgotpwd16 6y ago>"I'm on a portable, touch-enabled device". That's what the user-agent is[0]. And all major browser engines have/had a Mobile token on relevant devices. [0]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#os https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_de...
- freebreakfast 6y agoGoogle is moving toward that not being the case[0]. [0] https://www.zdnet.com/article/google-to-phase-out-user-agent-strings-in-chrome/ https://www.zdnet.com/article/google-to-phase-out-user-agent...
- forgotpwd16 6y agoClient hints (proposed successor) are the same thing but more selective. That is a site has to request extra information rather being given right away. Among them are platform and mobileness.