如何根据用户操作系统更改CSS
问题描述:
如何编写在Mac OS上处理不同效果而在其他OS版本上处理不同效果的CSS.
How can i write CSS that handle a different effect on Mac OS and different on other OS versions.
即
.(mac){
height: 100%;
width: 100%;
overflow: hidden;
}
.(win and linux){
height: 100%;
width: 100%;
overflow: scroll;
}
答
您不能使用纯CSS做到这一点,可以使用JavaScript检测MAX或WIN之类的操作系统,然后使用它来加载不同的CSS样式.
You cannot do this with pure CSS, you can detect OS like MAX or WIN with JavaScript, and then use that to load different CSS styles.
您可以使用window.navigator
的结果来查找有关操作系统的信息.
You can use the result of window.navigator
to find information about the OS.
console.log(window.navigator);