iPhone Safari 上的定位和字体大小问题
我正在尝试使这个网站: http://501commons.org 在 iPhone 上呈现与其他浏览器相同的效果。在 Android 上它运行得很好。我已经将 -webkit-text-size-adjust: 100%;
添加到正文样式中,这有点帮助。以下部分仍然无法正常工作,我不明白为什么移动 safari 无法正确显示它们:
- 左上角的徽标不会显示出来,
- 右上角的搜索框距离搜索框太远了 标题中左侧
- 的红色标语“非营利组织资源等”太大、太低,并且超出了右边框
- 三个导航菜单项(探索公共资源、志愿者、投资)的字体太大
其他一切似乎好吧,至少在主页上是这样。奇怪的是,上述四个问题都出现在 header 中。
任何帮助将不胜感激! 谢谢!
I'm trying to make this website: http://501commons.org render the same on iPhone as on other browsers. On Android it works just fine. I have already added the -webkit-text-size-adjust: 100%;
to the body style, which helped a little. What is still not working are the following pieces, and I can't figure out why mobile safari is not displaying them properly:
- the top left logo just plain won't show up
- the search box in the top right is way too far to the left
- the red slogan in the header "A Resource for Nonprofits etc" is too large, too low, and extends beyond the right border
- the font of the three nav menu items (Explore the Commons, Volunteer, Invest) is too large
Everything else seems ok, at least on the home page. What's weird is that all four problems above occur in the header.
Any help would be hugely appreciated!
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现:
左上角徽标
徽标未显示是由于奇怪的非级联问题。徽标是
内的
选项卡。
#portal-logo
在适用于它的倒数第二个样式表中有一个display: inline-block;
规则,但在最后一个样式表中没有。换句话说,这就是我们所拥有的:将
display: inline-block;
添加到最后一个样式表,神奇地使徽标出现。然后我还必须摆弄margin
s、position
、top
等以使其出现在正确的位置,但所有这些都在仅在移动浏览器上有条件加载的 CSS 文件,所以没问题。真的很奇怪,iOS 上的 Safari 没有级联display: inline-block;
样式!搜索框
我通过向其容器添加
text-align:right;
使搜索框呈现在正确的位置,尽管早期针对同一容器的规则为 < code>text-align:left; 使其在其他所有浏览器中都能正常工作。口号
口号需要最多的调整。它包含在
中。这是旧规则:
这是适用于移动 Safari 的新规则:
主要区别之一是以 px 为单位的绝对
font-size
,而不是百分比值。菜单项字体
同样,以 px 而不是 % 指定
font-size
似乎是这里的关键:旧:
新:
YMMV!
I figured it out:
Top left logo
The logo not showing up was due to a strange non-cascading issue. The logo is an
<img>
tab inside an<a id="portal-logo" ...>
. The#portal-logo
has adisplay: inline-block;
rule in the next-to-last stylesheet that applies to it, but not in the last one. In other words, this is what we have:Adding
display: inline-block;
to the last stylesheet magically makes the logo appear. Then I had to also fiddle withmargin
s,position
,top
, etc to make it appear in the right place, but all these are in a CSS file that is loaded conditionally only on mobile browsers, so it's ok. It's just really strange that Safari on iOS does not cascade thedisplay: inline-block;
style!Search box
I made the search box be rendered in the proper place by adding
text-align:right;
to its container, even though an earlier rule for the same container withtext-align:left;
makes it work just fine in every other browser.Slogan
The slogan required the most tweaking. It's contained in a
<div id="slogan">
. Here is the old rule:And here is the new rule that works on mobile safari:
One of the key differences is the absolute
font-size
in px, instead of as a % value.Menu Items font
Likewise, specifying the
font-size
in px instead of % seemed to be the key here:Old:
New:
YMMV!