Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 浏览器大小html css_Iphone_Html_Css_Resize - Fatal编程技术网

Iphone 浏览器大小html css

Iphone 浏览器大小html css,iphone,html,css,resize,Iphone,Html,Css,Resize,我一直在使用以下css代码: #MainBox { width: 488px; height: 181px; position: absolute; left: 50%; top: 236px; margin-left: -244px; //this being half the width } 确保页面上的项目居中。问题是,当我在iphone上看到这个页面时,我假设在其他智能手机上看到类似的页面,页面的左侧会被切掉!有人知道我如何解决这个问题,

我一直在使用以下css代码:

#MainBox
{   width: 488px;
    height: 181px;
    position: absolute;
    left: 50%;
    top: 236px; 
    margin-left: -244px; //this being half the width
} 
确保页面上的项目居中。问题是,当我在iphone上看到这个页面时,我假设在其他智能手机上看到类似的页面,页面的左侧会被切掉!有人知道我如何解决这个问题,并使一切正常吗


谢谢大家!

使用CSS将元素向左移动244px,而iphone屏幕太小,导致它被切断。试试这个:

#MainBox{
    width: 488px;
    height: 181px;
    margin: 236px auto 0 auto;
}

上面将div居中的技术有点过时。
使用margin:auto、width设置为您已有的固定值,并将父位置设置为relative。

我应该补充的是,这种CSS并不是所有屏幕大小的好解决方案,因为即使使用上述设置,您的内容也会被向下推236px,大约是iphone屏幕高度的一半。您应该研究带有媒体查询的响应式设计