News for hackers. Stuff that matters.
Re:Just because I have a vertical screen doesn’t mean I’m on... by nobleach on Tuesday February 02, 2021 @09:50AM (#26001559)
Yes, and webdevs have been trying for over 10 years now to figure out how to get this right. Has no one just stopped to consider having a browser send a `prefersMobileView` or `viewport:phone` or anything like that? I can remember back a few years ago, an iPhone 6+, turned sideways could get a desktop view on some sites... simply because it met the requirements set by the author. Now, the author's assumptions were wrong of course, but all we have to go on, is literally guesswork. We're told constantly NOT to use user-agent strings, but honestly, it's like we really need something to key off of. I know the A List Apart folks would have us create content that can be viewed on ANY viewport, but I consider that a tad bit unrealistic. I've been out of Front-end dev for a few years though, so perhaps things have changed.
Re:Just because I have a vertical screen doesn’t mean I’m on... by jefftk on Tuesday February 02, 2021 @09:57AM (#26001639)
Mobile vs Desktop is not a clean division: screens run the full range of widths. Instead, developers should:

* Lay out content based on the viewport width, in CSS pixels.

* Use larger tap targets for coarse pointers (https://developer.mozilla.org/en-US/docs/Web/CSS/@media/poin...).

Re:Just because I have a vertical screen doesn’t mean I’m on... by jon-wood on Tuesday February 02, 2021 @12:13PM (#26003631)
I had no idea that detecting coarse pointers was a thing, thanks for calling that out!
Re:Just because I have a vertical screen doesn’t mean I’m on... by badsectoracula on Tuesday February 02, 2021 @01:25PM (#26004611)
> Lay out content based on the viewport width, in CSS pixels.

This is wrong because the viewport width is not the same as the monitor width or the DPI: especially on big monitors running the browser fullscreen is very hard to use (my browser rarely exceeds more than ~50% width on a 2560x1440 monitor and even when i use a 1366x768 monitor - which btw is at 22", not some tiny laptop one - i very rarely use it maximized).

Re:Just because I have a vertical screen doesn’t mean I’m on... by jefftk on Tuesday February 02, 2021 @01:45PM (#26004868)
The viewport width is the browser width, not the screen width. What are you saying is wrong with using the viewport width?
Re:Just because I have a vertical screen doesn’t mean I’m on... by badsectoracula on Tuesday February 02, 2021 @01:56PM (#26005019)
Uh, i wrote "viewport width is not the same as the monitor width", this is the same as what you wrote.

As for why it is wrong, it is because you can't rely on it to make a Mobile vs Desktop distinction - i already provided an example why.

Re:Just because I have a vertical screen doesn’t mean I’m on... by jefftk on Tuesday February 02, 2021 @02:10PM (#26005176)
"Mobile vs desktop" is not a distinction websites should be making. Sites should make the best use they can of the available horizontal space.

It's still not clear to me where you think this approach gives bad results?

Re:Just because I have a vertical screen doesn’t mean I’m on... by badsectoracula on Wednesday February 03, 2021 @07:37AM (#26013077)
The problem is that the horizontal space only tells you how many pixels are available, not how big whatever you use those pixels for ends up on the screen.

The precise vs coarse isn't helpful either for something like this because this isn't just about clicking vs tapping, it is about how the end result looks - and there are PCs with both very small monitors and very big monitors (and relatively large monitors with low DPI or small monitors with very high DPI). CSS pixels only help for setting sizes/positions, but not layout.

AFAIK the best that can be done nowadays is resolution media queries but that isn't available everywhere (at least according to caniuse).

Of course in practice i expect none of the above to be used and have my browser simply zoom out whenever i reach many sites just because i do not want to maximize my browser :-/

Re:Just because I have a vertical screen doesn’t mean I’m on... by jefftk on Wednesday February 03, 2021 @07:59AM (#26013211)
CSS pixels are good for layout, not just sizes and positions, because a pixel (in a browser) now represents an apparent size. That is, if the user has a large device far from their face, or a small device close to their face, a pixel represents a similar portion of their vision. If they want things larger, they can adjust the scaling so a pixel represents a larger apparent size, or the reverse.
Re:Just because I have a vertical screen doesn’t mean I’m on... by badsectoracula on Thursday February 04, 2021 @10:49PM (#26032882)
This is never true in practice though and what you describe is just about sizes and position, you can't change the layout with CSS pixels - you need resolution media queries for that.
Re:Just because I have a vertical screen doesn’t mean I’m on... by karpierz on Tuesday February 02, 2021 @03:16PM (#26006018)
Ergonomics of using touch screen vs. mouse.

Usage while walking/moving vs. sitting/standing at a desk.

Re:Just because I have a vertical screen doesn’t mean I’m on... by jefftk on Tuesday February 02, 2021 @04:00PM (#26006575)
For touch screen vs mouse, use "pointer:coarse": https://developer.mozilla.org/en-US/docs/Web/CSS/@media/poin...

Most "mobile" usage is actually stationary, typically seated. If you really need to change layout based on motion you can use the accelerometer, but I can't see why you would?

Re:Just because I have a vertical screen doesn’t mean I’m on... by asddubs on Tuesday February 02, 2021 @12:58PM (#26004252)
IMO the best solution is to just have natural breakpoints (i.e. when a part of the design of the given page would cease to work, add a breakpoint to change the format of that component, rather than at predefined points) and then for logged in users have an option to request the desktop design, which you can do by simply setting a viewport to 1000px width and leaving everything else unchanged

what would be really nice would be element-size-based media queries. you can use javascript to do it but that sucks

Re:Just because I have a vertical screen doesn’t mean I’m on... by ryandrake on Tuesday February 02, 2021 @02:33PM (#26005468)
I think we really need to be able to more cleanly separate content from the design, and let the browsers, a.k.a. user-agents, decide/override more. Browsers have ceded too much control over layout and visual structure to web designers, who go on to make (often incorrect) assumptions about how the user wants to interact with their content.
Re:Just because I have a vertical screen doesn’t mean I’m on... by asddubs on Tuesday February 02, 2021 @03:53PM (#26006488)
the problem is that there is no distinction between a webapp and a document, the line is thoroughly blurred. For documents, you can probably just override a fair bit of schenanigans and things will still work, if look somewhat ugly, but for a spreadsheet app that's a rube goldberg machine of javascript and continuously regenerated html and css, it'll just turn it into a broken mess. the browser has become the de facto cross compatible application platform, which requires handing a lot of control to websites.
Re:Just because I have a vertical screen doesn’t mean I’m on... by tshaddox on Tuesday February 02, 2021 @06:13PM (#26008371)
That sounds similar to a CSS proposal called container queries, which has been a much-requested feature for many years. Currently the only native way to do responsive design is to make styling changes based on attributes of the viewport (like width). But like you say, it would be nice to have dynamic layouts for every individual component of a website. Container queries do that.
Re:Just because I have a vertical screen doesn’t mean I’m on... by asddubs on Tuesday February 02, 2021 @11:42PM (#26010681)
yeah I heard of those, I was blanking on the name, thanks for pointing that out. Another thing I really want would be position:device-fixed; but that one doesn't even seem to really be on the table for the most part.
Re:Just because I have a vertical screen doesn’t mean I’m on... by jiofih on Tuesday February 02, 2021 @11:50AM (#26003288)
One of the original selling points of the iPod touch/iPhone was that it could display full desktop websites...
Re:Just because I have a vertical screen doesn’t mean I’m on... by klodolph on Tuesday February 02, 2021 @12:57PM (#26004245)
Fair, although back at the time they came out it meant something different. Mobile-optimized websites in 2008 were horrible, stripped-down things.
Re:Just because I have a vertical screen doesn’t mean I’m on... by chungy on Tuesday February 02, 2021 @01:32PM (#26004715)
Isn't that still true in 2021? I haven't been particularly fond of the mobile view of most sites I come across. I force desktop-view on my phone fairly frequently just to get at features/pages I want.
Re:Just because I have a vertical screen doesn’t mean I’m on... by jefftk on Tuesday February 02, 2021 @01:47PM (#26004895)
It is still maybe a little bit true, where some sites will make some things only possible to do on desktop, but when the iPhone came out mobile sites were generally incredibly minimal. They needed to be, to handle existing devices and browsers, which were much less powerful than the iPhone.
Re:Just because I have a vertical screen doesn’t mean I’m on... by iso1631 on Wednesday February 03, 2021 @05:47AM (#26012472)
Mobile websites pre 2008 tended to be WML over WAP. If they existed they were terrible, probably created by an intern once and not updated, because very few people used mobile phones for internet access (other than say linking their PDA or notebook to their phone via IRDA)
Re:Just because I have a vertical screen doesn’t mean I’m on... by madeofpalk on Tuesday February 02, 2021 @09:33PM (#26009899)
No, not at all in the sense as it was in 2008.
Re:Just because I have a vertical screen doesn’t mean I’m on... by iamben on Tuesday February 02, 2021 @12:58PM (#26004259)
It can. As can Chrome on Android. Just request the "Desktop site" version. It's pretty unusable though, which is why we have responsive websites :-)