我在我的頁面上放置了一個畫布,並且想要將它切換爲填充頁面和向後。我的頁面通常是「高」,然後是屏幕高度,因此我的頁面上有一個滾動條。這種滾動條簡化版,隱藏當我設置我的畫布的大小一樣,在我的CSS:畫布切換填充整頁移除滾動條
canvas {
display: inline;
outline: 0;
margin: 50;
border: 1px solid #E0E0E0;
}
canvas.fullscreen {
display: block;
position: absolute;
top: 0;
left: 0;
border: none;
margin: 0;
}
我的JavaScript看起來像這樣:
//toggle the fullscreen mode
function fullscreen() {
if (!fullWindowState) {
fullWindowState = true;
//canvas goes full Window
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
canvas.className = "fullscreen"
} else {
fullWindowState = false;
//canvas goes normal
canvas.width = 820;
canvas.height = 600;
canvas.className = "";
}
}
完整的代碼是在github頁面上gh頁 http://patsimm.github.io/mandelight/
我真的不知道當畫布處於「全屏」模式時如何刪除滾動條。每一個幫助都是絕好的!
謝謝! patsimm
我看不到滾動條在最新的火狐v33.0.2 – Hacknightly 2014-11-04 21:24:41
即時通訊使用Firefox v33.0和theres絕對滾動條。我的筆記本電腦有相當小的屏幕。 Chrome v38.0.2125.111也有同樣的問題。 – patsimm 2014-11-04 21:27:28
你有沒有試過應用'身高:100%;溢出:隱藏「HTML和身體,而在全屏模式? '(function(){var s = document.createElement(「style」); s.type =「text/css」; s.textContent =「html,body {height:100%; overflow:hidden;}」; document .head.appendChild(s);})();'在控制檯似乎修復它。 – canon 2014-11-04 21:28:11