根据显示器分辨率缩放网站? [英] Zoom website depending on monitor resolution?

查看:169
本文介绍了根据显示器分辨率缩放网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个javascript来根据viwewers屏幕分辨率更改网站的缩放。我用1920x1080p在我的桌面上制作了网站:/

I'm looking for a javascript to change the zoom of the website depending on the viwewers screen resolution. I made the website on my desktop with 1920x1080p :/

html { -moz-transform: scale(0.75, 0.75); zoom: 0.75; zoom: 75%; }

我在我的css中得到了这个,以便将网站缩放到我喜欢的MacBook(1280 x 800) 。

I got this in my css to zoom the website to my liking for MacBook (1280 x 800).

但是我不知道如何使用javascript启用/禁用它(如果可能的话?)以及如何检测分辨率。

However I have no idea how to enable/disable it using javascript (if its possible?) and how to detect the resolution.

任何帮助都是适当的! :)

Any help is appriciated! :)

推荐答案

css @media查询会帮助你,不需要javascript.for示例

css @media queries will help you,don't need javascript.for example

@media screen and (max-width: 1280px) {
  html {
    -moz-transform: scale(0.75, 0.75);
    zoom: 0.75;
    zoom: 75%;
  }
}
@media screen and (max-width: 800px) {
  html {
    -moz-transform: scale(0.50, 0.50);
    zoom: 0.50;
    zoom: 50%;
  }
}

如果你特别想要javascript然后看看窗口对象 w3schools

if you specifically want javascript then look at window screen object w3schools

 <script>alert("Screen Width: " + screen.width);</script>

这篇关于根据显示器分辨率缩放网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆