如果您的稍微奇怪的 CSS 代码适用于 Windows 上的所有浏览器,那么它也适用于 Mac 和 Linux 吗?

发布于 2024-07-07 16:38:24 字数 378 浏览 16 评论 0原文

我正在测试我编写的一些看起来很奇怪的 CSS 代码(基本上,我混合使用百分比和像素值来表示 DIV 的宽度)。 虽然我不相信它是正确的,但它在 IE 5.5、IE 6.0 上的所有屏幕尺寸上都能完美运行(感谢这些人!)、IE 7.0、Firefox 3.0 和 Safari 3.12...全部运行在 Windows XP 上。 我是否需要进一步担心在 Mac 和 Linux 上测试代码,或者它很可能在这两个平台上正常工作?


编辑:

经过几个月的解决这个问题,我发现 Safari 和 Firefox 在 Mac 和 PC 之间惊人地一致。

I am testing some weird-looking CSS code that I wrote (I'm using a mix of percentages and pixel values for width of DIVs, basically). While I'm not convinced that it's right, it works perfectly on all screen sizes on IE 5.5, IE 6.0 (thanks to these guys!), IE 7.0, Firefox 3.0 and Safari 3.12... all on Windows XP. Do I need to further worry about testing the code on Mac and Linux, or will it most likely work on these two without fail?


Edit:

After a few months of working with this problem, I've found that Safari and Firefox are amazingly consistent between Mac and PC.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(7

旧竹 2024-07-14 16:38:24

它可以在 Mac 和 Linux 上运行吗?

不必要。

字体渲染是这种跨平台的最大问题。 Windows 上可用的某些字体默认情况下不包含在其他字体中,并且 OSX 具有非常重的字体渲染模型(尽管 Windows 上的 Safari 应该显示这一点 - 至少以前是这样)。

一般的盒子模型,padding,margin等都应该是标准的。

will it work on Mac and Linux?

Not necessarily.

Font rendering is the biggest issue with that sort of cross-platform. Some fonts that are available on Windows are not included in others by default and OSX has a very heavy font-rendering model (though Safari on Windows should show this - at least it used to).

General box models, padding, margins, et al should all be standard.

2024-07-14 16:38:24

http://browsershots.org/

这将允许您跨多个平台(包括 Linux)在多个浏览器中查看您的网站)。 然而,我要强调的是,让您的网站在每个网站中看起来 100% 完全相同的可能性几乎是不可能的,有时您必须满足于 99%。

考虑您的目标受众以及他们通常会使用的浏览器/操作系统。 另外,网站启动后,运行一些统计跟踪(例如 Google 分析)并确定正在发生的情况被你的观众使用。

http://browsershots.org/

This will allow you to view your site in multiple browsers across multiple platforms (Linux Included). However, may I stress that the chances of you getting your website to look 100% identical in each one is virtually impossible, and sometimes you have to settle for 99%.

Think about your target audience and what browser/OS they're typically going to use. Also, after the site is up, run some stat tracking (like Google analytics) and identify what's being used by your audience.

夏有森光若流苏 2024-07-14 16:38:24

mac 领域非常棘手。 不同的操作系统版本有不同的 safari 版本,因此如果没有一堆 Mac 进行测试,它会变得非常困难。 如果它在 Windows 版 Safari 上看起来不错,那么它在 Mac 版 Safari 上也很可能会很好看。 特别是如果您主要关心的是 div 宽度。

Linux 有很多浏览器,我严重怀疑是否有人测试过所有浏览器。 由于 Firefox 在 Linux 上运行,因此您已经占据了 Linux 市场的很大一部分。

您测试过的浏览器已经超过 95% 的浏览器市场

the mac realm is very tricky. different operating system versions have different safari versions so it makes it really tough without having a bunch of macs for testing. if it looks good on safari for windows, chances are it will look good on safari for the mac. especially if your main concern is with div widths.

linux has a slew of browsers and i seriously doubt anyone out there tests all of them. since firefox runs in linux, you've got a good percentage of the linux market covered.

you already have over 95% of the browser market covered with the browsers you have tested.

生生漫 2024-07-14 16:38:24

OS X 有许多基于WebKit 的浏览器,即Safari/Shiira/iCab/OmniWeb,以及Firefox/SeaMonkey/Camino 和Opera。 我没有统计数据,但我猜这至少覆盖了所有用户的 98%。

Debian 人气竞赛的结果:(

w3m            85.93%
iceweasel      60.35%
lynx           25.71%
konqueror      21.95%
links           9.23%
iceape-browser  6.69%
elinks          6.51%
links2          4.09%
dillo           2.70%
galeon          2.35%
epiphany        0.79%
w3m-el          0.75%
kazehakase      0.58%
midori          0.30%
arora           0.29%

这不会跟踪使用非 [DFSG]free* 软件的用户,例如Linux 用户是一个非常多元化的群体;例如 Mozilla Firefox 和 Opera。 即使您在 Windows 上使用 KDE 4 中的 Mozilla Firefox、Opera 和 Konqueror 进行测试,您也无法覆盖大部分用户群。

话虽这么说,如果您将注意力集中在支持现代 CSS 的浏览器上,您会发现只有几个底层引擎:Trident (IE)、Gecko (Mozilla)、WebKit (Apple)、KHTML (KDE) 和急板(歌剧)。 单独来看:

  • Trident:仅由 Windows 中的 IE 使用,您已经在测试它。
  • Gecko:由 Mozilla Suite 的浏览器(Mozilla Navigator、SeaMonkey Navigator、IceApe Navigator、Mozilla Firefox、IceCat、IceApe、Epiphany-Gecko、Galeon、Kazehakase-Gecko)使用。 字体、图像和插件渲染确实因平台而异。
  • WebKit:由 Safari/Shiira/iCab/Omniweb、Google Chrome、Epiphany-WebKit、Kazehakase-WebKit、Arora 使用。 所有 OS X 浏览器的渲染应该完全一致,因为它们使用系统提供的 WebKit 库,但 Windows 上的 Safari 和 Google Chrome 底层有非常不同的绘图引擎,Linux 上有 Gtk+ 和 Qt 版本,具有不同的行为。
  • KHTML:WebKit 是从它分叉出来的,但它的开发一直独立进行,因此存在相当大的分歧。 主要由 Konqueror 使用。 KDE 4 的 Konqueror 已移植到 Windows 和 OS X,其行为非常相似; 然而,KDE 4 的 KHTML 比 KDE 3 有了显着的进步,并且仍然被广泛使用。
  • Presto,用于 Opera 7 及以上版本。 跨平台一致。

正如另一个答案提到的,每个引擎的 HTML 解析和 CSS 框模型在不同平台上是不变的。 只有像字体、图像和插件这样的“小”东西才会有不同的表现。

OS X has many WebKit-based browsers, i.e. Safari/Shiira/iCab/OmniWeb, as well as Firefox/SeaMonkey/Camino and Opera. I don't have stats, but I'd guess that this covers at least 98% of all users.

Results from Debian Popularity Contest:

w3m            85.93%
iceweasel      60.35%
lynx           25.71%
konqueror      21.95%
links           9.23%
iceape-browser  6.69%
elinks          6.51%
links2          4.09%
dillo           2.70%
galeon          2.35%
epiphany        0.79%
w3m-el          0.75%
kazehakase      0.58%
midori          0.30%
arora           0.29%

(This does not track users with non-[DFSG]free* software, such as Mozilla Firefox and Opera.) Linux users are a very diverse crowd; even if you test with Mozilla Firefox, Opera, and Konqueror from KDE 4 on Windows, you're not even close to covering most of the userbase.

That being said, if you narrow your focus to browsers with support for modern CSS, you'll find that there's only a few underlying engines: Trident (IE), Gecko (Mozilla), WebKit (Apple), KHTML (KDE), and Presto (Opera). Taking these individually:

  • Trident: only used by IE in Windows, you're already testing it.
  • Gecko: used by the Mozilla Suite's browser (Mozilla Navigator, SeaMonkey Navigator, IceApe Navigator, Mozilla Firefox, IceCat, IceApe, Epiphany-Gecko, Galeon, Kazehakase-Gecko). Font, image, and plugin rendering do vary wildly from platform to platform.
  • WebKit: used by Safari/Shiira/iCab/Omniweb, Google Chrome, Epiphany-WebKit, Kazehakase-WebKit, Arora. Rendering should be completely consistent across all OS X browsers, as they use the system-provided WebKit library, but Safari and Google Chrome on Windows have very different drawing engines underneath, and on Linux there's both Gtk+ and Qt versions, with different behavior.
  • KHTML: WebKit was forked from it, but its development has continued independently, and so there is a fair amount of divergence. Used primarily by Konqueror. KDE 4's Konqueror has been ported to Windows and OS X, behaving very similarly; however, KDE 4's KHTML has advanced significantly over KDE 3's, still in common usage.
  • Presto, used in Opera 7 and above. Consistent across platforms.

As mentioned by another answer, HTML parsing and the CSS box model for each engine is unchanged across platforms. It's only the "little" stuff like fonts, images, and plugins which will act differently.

丢了幸福的猪 2024-07-14 16:38:24

根据我的经验,Mac 和 Win 上的 FF3 渲染效果并不完全相同,但仍然足够接近,无需费心检查两者。

in my experience FF3 on Mac and Win does not render exactly the same, but still close enough to not bother checking both.

夜唯美灬不弃 2024-07-14 16:38:24

它很可能会起作用,尽管我见过一些例子,在 Windows 上的 FF3 中可以工作,但在 OS X 上的 FF3 上却不行。

It will most likely work, though I have seen instances where something works in FF3 for Windows, yet doesn't for FF3 on OS X.

撑一把青伞 2024-07-14 16:38:24

我同意,字体渲染在 FF3 win/mac 上会有所不同,并且给我带来了一些定位问题

I concur, font rendering will vary on FF3 win/mac and has caused some positioning issues for me

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