css - Chrome 的全屏 Canvas ?

标签 css html google-chrome canvas

我正在尝试在 Google Chrome 上制作全屏 Canvas 。

<style>
#canvas:-webkit-full-screen {
    height:100%;
    width: 100%;
}    
</style>
<button onclick="fullScreen()">Full Screen</button>
<canvas id="canvas"></canvas>
<script>
    function fullScreen() {
        var c = document.getElementById("canvas");
        c.webkitRequestFullScreen();
    }
</script>

此代码使 Canvas 全屏,但只有高度全屏。

最佳答案

尝试将 CSS 规则 fixed 用于 position 与 canvas 元素:

position:fixed;
left:0;
top:0;
width:100%;
height:100%;

您可能还需要将 htmlbody 的宽度/高度设置为 100%。

如果你想避免缩放,因为这会给你,你需要直接设置 Canvas 元素的宽度和高度(使用 window.innerHeight.innerWidth).

关于css - Chrome 的全屏 Canvas ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18927126/

相关文章:

jquery - 如何编辑 Bootstrap 移动折叠下拉菜单布局?

html - 使用 css flex 网格图像

html - jquery ajax 在 IE9 中导致内存泄漏

javascript - 以编程方式计算 Google Chrome 中页面加载的完成时间

google-chrome - Chrome 中的 GWT 插件问题

html - CSS/HTML : Separate background from divs

css - 设置一个 :visited link to same state as a:link and a:hover

html - Bootstrap 按钮上的 Wordwrap 不起作用

html - 如何将按钮转换为这种样式的按钮

google-chrome - 编译错误 : WebAssembly. 编译()