iPhone Safari 上的定位和字体大小问题

发布于 2024-12-06 17:16:37 字数 456 浏览 1 评论 0原文

我正在尝试使这个网站: 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感受沵的脚步 2024-12-13 17:16:37

我发现:

左上角徽标

徽标未显示是由于奇怪的非级联问题。徽标是

#portal-logo {       /* in the last CSS file */
   margin-bottom: 0;
}

#portal-logo {      /* in the next-to-last CSS file */
   display: inline-block;
   margin: 1.375em 0;
}

display: inline-block; 添加到最后一个样式表,神奇地使徽标出现。然后我还必须摆弄 margins、positiontop 等以使其出现在正确的位置,但所有这些都在仅在移动浏览器上有条件加载的 CSS 文件,所以没问题。真的很奇怪,iOS 上的 Safari 没有级联 display: inline-block; 样式!

搜索框

我通过向其容器添加 text-align:right; 使搜索框呈现在正确的位置,尽管早期针对同一容器的规则为 < code>text-align:left; 使其在其他所有浏览器中都能正常工作。

口号

口号需要最多的调整。它包含在

中。这是旧规则:

#slogan {
  color: #EE3524;
  float: right;
  font-size: 110%;
  font-weight: bold;
  margin-right: -190px;
  padding-top: 60px;
  position: relative;
  z-index: 1;
}

这是适用于移动 Safari 的新规则:

#slogan {
  -webkit-text-size-adjust: 100%;
  clear:right;
  color:#ee3524;
  font-size:17.6px;
  font-weight: bold;
  float:right;
  margin-right:0px;
  padding-bottom:50px;
  padding-top:0px;
  position:relative;
  text-align:right;
  z-index:1;
}

主要区别之一是以 px 为单位的绝对 font-size,而不是百分比值。

菜单项字体

同样,以 px 而不是 % 指定 font-size 似乎是这里的关键:

旧:

#portal-globalnav li a {
  background-color: transparent;
  color: #FFFFFF;
  font-size: 1.2em;
  font-weight: bold;
  min-width: 3em;
  padding-bottom: 11px;
}

新:

#portal-globalnav li a {
  background-color:transparent;
  color:#fff;
  font-size:15.4px;
  font-weight:bold;
  padding-bottom:11px;
  min-width:3em;
}

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 a display: 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:

#portal-logo {       /* in the last CSS file */
   margin-bottom: 0;
}

#portal-logo {      /* in the next-to-last CSS file */
   display: inline-block;
   margin: 1.375em 0;
}

Adding display: inline-block; to the last stylesheet magically makes the logo appear. Then I had to also fiddle with margins, 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 the display: 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 with text-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:

#slogan {
  color: #EE3524;
  float: right;
  font-size: 110%;
  font-weight: bold;
  margin-right: -190px;
  padding-top: 60px;
  position: relative;
  z-index: 1;
}

And here is the new rule that works on mobile safari:

#slogan {
  -webkit-text-size-adjust: 100%;
  clear:right;
  color:#ee3524;
  font-size:17.6px;
  font-weight: bold;
  float:right;
  margin-right:0px;
  padding-bottom:50px;
  padding-top:0px;
  position:relative;
  text-align:right;
  z-index:1;
}

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:

#portal-globalnav li a {
  background-color: transparent;
  color: #FFFFFF;
  font-size: 1.2em;
  font-weight: bold;
  min-width: 3em;
  padding-bottom: 11px;
}

New:

#portal-globalnav li a {
  background-color:transparent;
  color:#fff;
  font-size:15.4px;
  font-weight:bold;
  padding-bottom:11px;
  min-width:3em;
}

YMMV!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文