问题描述
我在Canvas中创建了一个小游戏,但我遇到了问题。
默认缩放设置为100%以外的某些用户无法看到整个游戏页面......
我在网上搜索了一个解决这个问题的方法,但找不到一个...
我已经在CSS中使用过:
zoom:100%; p>
< meta name =viewportcontent =initial-scale = 1.0,minimum-scale = 1.0,maximum-scale = 1.0/> gt ;
和
style = zoom:75%
有人可以帮助我。
谢谢你可以在页面加载中设置 zoom 属性
document.body.style.zoom = 1.0
但是, zoom 是,我推荐usi ng transform 改为。
var scale ='scale(1)' ;
document.body.style.webkitTransform = scale; // Chrome,Opera,Safari
document.body.style.msTransform = scale; // IE 9
document.body.style.transform = scale; // General
I created a little game in Canvas, but I have a problem.
Some users who have the default zoom set to something other than 100% can't see the entire game page...
I searched on the internet for a solution to this problem but couldn't find one...
I have already used:
zoom: 100%; in CSS.
<meta name="viewport" content="initial-scale=1.0 , minimum-scale=1.0 , maximum-scale=1.0" />
and
style="zoom: 75%"
Can someone help me please.
Thank you
You can set zoom property on page load
document.body.style.zoom = 1.0
But, zoom is not a standard property for all browsers, I recommend using transform instead.
var scale = 'scale(1)'; document.body.style.webkitTransform = scale; // Chrome, Opera, Safari document.body.style.msTransform = scale; // IE 9 document.body.style.transform = scale; // General
这篇关于用JS强制页面缩放100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!