Viewport questions

I am trying to better understand how mobile devices and the meta viewport tag work.

Question #1:
In the article Quick Tip: Don’t Forget the Viewport Meta Tag, the author says…

I don’t understand this! Why would iOS Safari assume the webpage is 980px wide?

On my MacBook, Chrome isn’t assuming (or making) the webpage 980px. Instead, it seems my monitor is 1280px.

Question #2:

Why does this happen?

Question #3:

What does this mean?

Question #4:

@-ms-viewport{    width: extend-to-zoom;    zoom: 1.0;}

Does that address @RyanReese mention of meta IE edge tag??

1 Like

Perhaps this article I wrote might clear things up - http://www.sitepoint.com/media-queries-width-vs-device-width/

Look at the Getting Started section, specifically.

Because not every developer will make the webpage responsive. It’s attempting to at least get some sort of default display that somewhat replicates the desktop environment.

The meta viewport tag will render it like a phone, or rather, what you probably want. It’s a bit more complicated, but the meta viewport is needed to make your page responsive.

THis is answered in my article.

I go over width vs device-width in my article. Basically, just because you change orientations, doesn’t change the width you are viewing at. So if you do deviec width, you need to account for landscape AND portrait. That’s why device-width is horrible.

No clue.

That code specifically? No.

That article seems to recommend that you place the viewport code in your css file like this…

    @viewport{
            zoom: 1.0;
            width: extend-to-zoom;
    }

    @-ms-viewport{
            width: extend-to-zoom;
            zoom: 1.0;
    }

Where in the world are you getting that code? Why are you referencing it :confused: ?

Doesn’t look to be widely supported

Mobile 

Android	Chrome for Android	Firefox Mobile (Gecko)	IE Mobile
4.4 	29 	 	 	Not supported 	 	10-ms[1]

Opera Mobile
11.10 Removed in 15 Reintroduced behind a flag in 16
Safari Mobile
Not supported

It’s from the (well-written) article above…

So what code should I use so I define viewport, don’t allow zooming, and gracefully can handle someone rotating their smartphone - as mentioned in the article above?

Times have changed since that article was written :slight_smile:

I will make this as simple as I can for you. Please pay attention.

  1. You do not need to worry about users rotating phones. The content should adapt if your website is made responsive via media queries. You shouldn’t forbid zooming. That’s just annoying. A responsive website is ideal for phones but perhaps an older person is using your website and they need to zoom in a smidge to read. Don’t forbid it.

Now, please read my article that I linked to. All you have to do is create a website, that when you take the browser edge, and make it smaller (until 300px or so), and you notice no breaks. That is a perfectly responsive website and will handle any issues with any phones, users rotating, etc. You should code a website that uses a few media queries to fix any issues that arise when you resize your page. E.g. at 500px, let’s say you notice that your 2 column layout would be best if they were stacked. Otherwise content is unreadable. That is where you should write am edia query for 500px and down to make them stack. Very simple. See an issue? Think of a possible solution. Then write a media query for it. This is all very simple. You should ignore the @viewport and do not get distracted by it. You are reading on the wrong things.

My approach to RWD is to utilise the free Google Test because that is the acid test. Create a link on your web page and keep testing.

Google Mobile Friendly Tester

Google has no doubt tested every possible mobile case that is on the market and has a section in Google Webmaster Tools displaying non-conforming pages.

That’s good, because you have a way of making things difficult sometimes.

I did read it. A month ago, and an hour ago. Funny, it doesn’t cover the things I asked about. Doesn’t talk about how smart phone no longer have issues when you rotate them. Hmm…

Does RWD include all bold for us old-timers as well? :wink:

Pretty authoritative tone there.

Reading an article from Tuts+ seems like a decent source.

And I asked here to verify things…

Handy link, but it won’t teach me what is right and wrong.

That is why I am trying to learn about the mechanics of RWD here.

Thank God Ryan is so patient tonight! :wink:

Not in bold so you may have missed it.

Also I should mention that if you were to go with device-width, you would have to also provide separate rules for orientation (portrait vs. landscape): device widths do not change simply because you rotate the device sideways. That’s adding even more code, and more headaches!

i.e. Do Not code for devices and you won’t have the problem.

1 Like

IMHO RWD is overrated and most web pages can be made responsive with basic CSS.

1 Like

If you actually did read my article, you mention that a caveat of device-width is taking into account orientations. I mention that the alternative means you don’t have to worry about it. Are you sure you read it?

I’ve mentioned these points to you for the past 4 months about 4-5 times now, so I’m trying anything and everything to make it stick :wink: .

Thanks!! :slight_smile:

Here’s a page on the MS X-UA meta tag identifying the options available - https://technet.microsoft.com/en-us/library/dn321432.aspx

It doesn’t provide the full tag though, so take a look at this link instead for a further reading https://www.modern.ie/en-gb/performance/how-to-use-x-ua-compatible

Very simply, just add the meta tag in the <head> section of your HTML page.

This is what I added earlier today…

    <!-- HTML Metadata -->
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

It would be worth expanding your viewport meta tag a little to this

<meta name="viewport" content="width=device-width, initial-scale=1">

https://developer.mozilla.org/en/docs/Mozilla/Mobile/Viewport_meta_tag

The other tags are fine.

1 Like

I think you may have misread that article. After showing that code, it goes on to say:

It’s a far more elegant solution than the metatag, but is a long way from being fully supported. Slot it into your CSS now, to make sure your responsive design behaves itself in IE10 “snap mode”, and keep an eye on its progress in the future. This is where viewport control is headed.

So he’s recommending it as well as - not instead of - the HTML <meta> tag.

##The Crux

If you read nothing else within this post, take one bit of advice away: if you’re designing flexibly, use the viewport meta tag in your . In its basic form, it will set you up for cross-device layout peace of mind:

[quote=“mikey_w, post:7, topic:196171”]
It’s from the (well-written) article above…
[/quote]You also need to remember that the article was written in February 2012, and updated in June 2013 - so it is two years old. Given the pace of development in this area, you really need to go with the most recent sources you can find.

1 Like