Iphone 浏览器大小html css
我一直在使用以下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上看到这个页面时,我假设在其他智能手机上看到类似的页面,页面的左侧会被切掉!有人知道我如何解决这个问题,
#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屏幕高度的一半。您应该研究带有媒体查询的响应式设计