Any difference between Chrome on Mac and Chrome on

2020-08-09 08:08发布

问题:

I am studying CSS3 and HTML5 and trying to develop a simple homepage. Since I have only Mac interface in my house so I couldn't check any differences on windows.

But one day, one of my acquaintances told me that there is a pixel difference between browsers which I didn't know at all. Then I checked my page and it appeared to be wrong.

Even though it was same resolution as I set, Chrome on Mac showed me an appropriate position of several buttons but Chrome on Windows didn't.

Their position was quite different and ruined the design. How can I fix this problem? or is it normal?

Thanks.

回答1:

Developing a site that is the same on every combination of operating system and browser is no easy task. It has personally added many hours to my development time trying to fix the issues.

There are several tools out there that try to help you with this task, such as Cross Browser Testing. Or you can manually test it by installing the browsers on your machine. It is also common to use virtual machines to test your website on other platforms. VMware is popular.

Using cross browser libraries can also aid in this. Such as jQuery, which is very popular. This page lists more information on the subject, in general.



回答2:

Difference is not in Chrome, but difference is in Mac and Windows. Here, you can detect the userAgent and add the appropriate class to the body tag (with jQuery):

jQuery(document).ready(function(){
 if(navigator.userAgent.indexOf('Mac') > 0){
  jQuery('body').addClass('mac-os');
 } else {
  jQuery("body").addClass("pc");
 }
});

After detecting userAgent, you can write css specially for Mac and Window and their browsers too.



回答3:

In 2018 chrome and firefox behave differently depending on the operating system. I built a site recently, and on latest chrome and firefox versions one page was rendering OK in windows, while on macOS and ubuntu, it had a small glitch. The elements that are supposed to be inline were displaying horizontally in certain states.