Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
806 views
in Technique[技术] by (71.8m points)

html - Why is my website cutting off on mobile devices?

I created this website with the original intention of having it be mobile. However I've had to take that function out and for the time being just wanted to have it so when you visit the site on a mobile device you just see the website as you would see on the screen. Not mobile friendly as you would want it to be but zoomed out so you can see the whole thing.

I've already placed in the code to make it behave the way I'd like it to but something is happening and it's not working. Ive looked into the HTML 5 shim and other options for the viewport but I can't figure it out.

I've tried a few different variations of the viewport tag

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

This is what the website looks like right now on mobile devices

enter image description here

This is what I was hoping to make it look like

like this screenshot

Can you see what I'm missing?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In your case you should not use any of the suggested meta viewport tags. If you leave the page without any meta viewport tags you should get the desired result in most mobile browsers.

You could add <meta name="viewport" content="width=980"> to tell the browser that you content is 980 px, if that is the case. You seem to have a 960 px wide page but it may look nicer to have some spacing on the sides.

I find this to be a nice article to explain the meta viewport tag

And this is another article about using the meta viewport tag for non-responsive pages

The meta viewport tags that you have tried tells the browser a few different things:


<meta name="viewport" content="width=device-width" /> 

This tells the browser that content width should fit in the device width. In order to use this successfully your page width should be adjustable to the device.


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

This tells the browser that it should zoom the page so that 1 CSS pixel from the page equals 1 viewport pixel on the screen (not physical pixels on e.g. Retina displays). This results in your page being zoomed in as it is wider then a normal mobile screen. Maximum-scale also tells the browser not to let you zoom the page any further than that.


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

This tells the browser that the content is 500 px wide and that you should zoom the page.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...