<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<style>
.me {
height: 100vh;
}
</style>
</head>
<body>
<div class="me" id="container"></div>
<script src="https://www.matrixlead.com/monaco-editor/min/vs/loader.js"></script>
<script>
require.config({ paths: { 'vs': 'https://www.matrixlead.com/monaco-editor/min/vs' }})
require(["vs/editor/editor.main"], function() {
var editor = monaco.editor.create(document.getElementById('container'), {
value: 'function x() {\n\tconsole.log("Hello world!");\n}',
language: 'javascript',
minimap: { enabled: false },
scrollBeyondLastLine: false
});
});
</script>
</body>
</html>
當我看到它在Chrome和上下滾動,沒有針對整個窗口的滾動條。看起來這是因爲編輯器的高度大於窗口的高度。我只是不想看到任何滾動條。有誰知道如何做到這一點?
編輯1:在Safari 9.1.2的截圖與height: calc(100% - 24px)
解決方案:
隨着答案的幫助下,這裏是解決方案爲我工作:
1)我們需要在一個獨立的html文件中進行測試,而不是在JSBin
2)的關鍵是使用overflow: hidden
3)其結果是,在滾動了下面的代碼不創建任何滾動條和向下,沒有隱藏在底線當代碼長:
<html>
<style>
body {
overflow: hidden;
}
.myME {
height: 100%
}
</style>
<body>
<div class="myME" id="container"></div>
<script src="https://www.matrixlead.com/monaco-editor/min/vs/loader.js"></script>
<script>
require.config({ paths: { 'vs': 'https://www.matrixlead.com/monaco-editor/min/vs' }})
require(["vs/editor/editor.main"], function() {
var editor = monaco.editor.create(document.getElementById('container'), {
value: 'function x() {\n\tconsole.log("Hello world!");\n}',
language: 'javascript',
minimap: { enabled: false },
automaticLayout: true,
scrollBeyondLastLine: false
});
});
</script>
</body>
</html>
「溢出:隱藏」的問題在於,當您用多行文本編寫文本時,文本的一部分確實隱藏在底部。這在Safari中尤其明顯。這不是我想要的。 – SoftTimur
解決方案是可以的人。將100vh更改爲98vh,問題消失.... –
但是'98vh'從哪裏來? – SoftTimur