Blackberry 移动网站的中心页面
我有一个移动网站,可以在我测试的每个浏览器上运行。尽管在黑莓手机上,整个页面似乎都是向左对齐而不是居中对齐。
有没有一种特定的方法可以让它像其他东西一样与中间对齐?你能像使用 IE 一样使用条件吗?我需要改为定位 body 标签吗?
目前它只是一个简单的边距:0 auto; - 如有任何帮助,我们将不胜感激。谢谢。
I have a mobile site that works on every browser I test it with. Though on a Blackberry the entire page seems to align to the left rather than in the center.
Is there a specific way to make it align to the middle like everything else? Can you use conditionals the way you would with IE? Do I need to target the body tag instead?
At the moment it's just a simple margin: 0 auto; - Any help is appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最初通过问同样的事情偶然发现了这个问题,然后我找到了一个解决方案(针对我的具体情况),我想我会分享。 (注意:我的网站在 iPhone 上的 Safari 中左对齐。)
我将网站分为几个部分,其中一些设置为最小宽度:1140px,而另一些设置为 960px。将左右边距设置为自动后,所有内容都以所有桌面浏览器为中心显示,正如它们应该的那样。
然而,那些较窄的部分在移动设备上是左对齐的,所以我只是将它们包装在一个 div 中,宽度:100%,最小宽度:1140px(或最宽的部分),边距:0 auto;一切都在移动设备上正常对齐:)
I originally stumbled upon this question by asking the same thing, then I figured out a solution (for my particular case), which I thought I'd share. (Note: my site left-aligned in Safari on my iPhone.)
I divided my site into sections, some of which were set to min-width: 1140px while others to 960px. With left and right margins set to auto, everything appeared centered on all desktop browsers, as they should.
However, those sections that were narrower were left-aligned on mobile, so I simply wrapped them in a div with width: 100%, min-width: 1140px (or your widest section), margin: 0 auto; and everything aligned normally on mobile :)
尝试将您想要居中的容器/内容包装在另一个元素中,并将文本对齐设置为居中。例如
Try wrapping the container/content you want centered in another element with text-align set to center. E.g.
<div style="text-align:center;width:100%;">
<div id="myContent" style="width:50%;"> </div>
</div>