简体   繁体   English

自动在iPad / iPhone上设置左右边距自动宽度和900px宽度,并具有额外的边距

[英]Margin left/right auto and 900px width is positioning with extra wide margin on the iPad/iPhone only

The following profile maintains centering in the main browsers in OSX and WinXp. 以下配置文件在OSX和WinXp中的主要浏览器中保持居中。 But is offset to the left in the iPad with the width shorten by the larger margin on the right. 但是在iPad中向左偏移,宽度缩短了右侧的较大边距。

.wrapper {
   width: 900px;
   margin-right: auto;
   margin-left: auto;
   position: relative;
   border: 1px solid #9B9B9B;
 }

<body>
   <div class="wrapper">
     :
   </div>
</body>

I have an inline unordered list containing thumbs that w/o java enabled extends to the right beyond the wrapper. 我有一个内联的无序列表,其中包含未启用Java的拇指延伸到包装器之外的右侧。 These images are contained within a div that is positive relative. 这些图像包含在正相对的div中。 Once JavaScript is enabled on the browsers, the page is centered. 在浏览器中启用JavaScript后,页面将居中。

Again, the problem is only in the iPad and the iPhone. 同样,问题仅存在于iPad和iPhone中。

Is there a possible reason for this? 可能有这个原因吗?

For mobile devices, all div boundaries must fit within the '.wrapper' with javascript disabled in order for the margin left/right auto to work. 对于移动设备,所有div边界都必须在禁用了JavaScript的'.wrapper'内,以使左右边距自动工作。

Once javascript executes, theres no problems with moving div's to the far left or right of the wrapper. JavaScript执行后,将div移动到包装器的最左侧或最右侧就没有问题。

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

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