简体   繁体   English

网站不适用于Ipad和iPhone

[英]Website doesn't fit on Ipad and iPhone

This is the website: 这是网站:

The problem is that the screen doesn´t adapts to the viewport (no white margin on the sides when first load) and also makes an strange big white margin right if you zoom out and see the entire page. 问题在于屏幕无法适应视口(第一次加载时侧面没有白色边距),而且如果缩小并查看整个页面,也会产生奇怪的大白色边距。

I´m using this tag to try to achieve but still doesn´t work too much: 我正在使用此标签来尝试实现,但效果仍然不高:

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=3.0, user-scalable=yes">
<meta name="apple-mobile-web-app-capable" content="yes" />

This is my css: 这是我的css:

body {
background-color:#fff;
font-family:'Droid Sans', arial, sans-serif;
color: #777;
width: 100%;
margin:  0;
}
#page {
width: 950px;
margin: 0px auto;
padding:0px;
background-color:#fff;
z-index: 0;
}

any ideas how can I fix it? 任何想法我该如何解决?

What you need is something called CSS media queries. 您需要的是称为CSS媒体查询的东西。 Basically you create different CSS rules for specific screen sizes. 基本上,您会为特定的屏幕尺寸创建不同的CSS规则。 For example 例如

@media screen and (max-width: 700px) and (min-width: 520px) {
  body {
    background: red;
  }
}

will set the body background to red color whenever your browser window/screen width is larger than 520px and smaller than 700px. 只要浏览器窗口/屏幕宽度大于520px且小于700px,就会将正文背景设置为红色。

Try googling for 'CSS media query' and 'responsive design', that'll point you in the right direction 尝试谷歌搜索'CSS媒体查询'和'响应式设计',这将指向你正确的方向

Your issue seems to be your slideshow and the viewport tag: 您的问题似乎是幻灯片和viewport标签:

#slideshow is set to width:1083px; #slideshow设置为width:1083px; which is causing the whitespace at the right on your site. 这导致网站右侧出现空白。 Change this to 100% and that will fix it. 将其更改为100%解决。 Even though the overflow is set to hidden the element 即使溢出设置为hidden元素

initial-scale=1.0 is what the size is rending when it initially loads. initial-scale=1.0是最初加载时大小为rending的内容。 It's loading at a 1:1 pixel ratio and not scaled down to see the entire page. 它以1:1的像素比率加载,而不是按比例缩小以查看整个页面。

width=device-width is setting the width of your page to the width of the device, which on iPhone's Mobile Safari is 320px. width=device-width将页面宽度设置为设备的宽度,iPhone的Mobile Safari上的宽度为320px。 If you alter this to something like width=950 that will set the width of the viewport equal to the width of your site, 950px. 如果您将此更改为width=950 ,将视口的宽度设置为等于站点的宽度,950px。 This will allow the user to scale all the way out and see the entire width of the site. 这将允许用户完全缩小并查看网站的整个宽度。 Safari will add whitespace to the bottom of your page. Safari会将空白添加到页面底部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM