Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/461.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将div放在ace编辑器的顶部_Javascript_Html_Css_Ace Editor - Fatal编程技术网

Javascript 将div放在ace编辑器的顶部

Javascript 将div放在ace编辑器的顶部,javascript,html,css,ace-editor,Javascript,Html,Css,Ace Editor,我正在网页中使用ace编辑器实例: <div class="tabpage" id="tabscontent"> <div class="ace_page" id="tabpage_1"> </div> </div> 现在,我想将div放在选项卡1中,这样它将位于使用以下代码的编辑器实例的顶部: function addUserCursor(editor, position, user, color) { var page

我正在网页中使用ace编辑器实例:

<div class="tabpage" id="tabscontent">
     <div class="ace_page" id="tabpage_1">
     </div>
</div>  
现在,我想将div放在
选项卡1
中,这样它将位于使用以下代码的编辑器实例的顶部:

function addUserCursor(editor, position, user, color) {
var page = document.getElementById("tabscontent");
var label = document.createElement("div");
label.setAttribute("id", editor+"-"+user);
label.setAttribute("position", "absolute");
label.setAttribute("top", "200px");
label.setAttribute("left", "200px");
label.setAttribute("background-color", color);
label.setAttribute("z-index", "10");
label.innerHTML = user;
page.appendChild(label);
}


但这不会导致编辑器顶部出现div(样式属性稍后将在css中收集,这仅用于测试)。有人知道我做错了什么吗?

label.setAttribute(“z-index”,“10”)错误,必须是
label.style.zIndex=10

ace编辑器使用了什么z-index?我也查看了它,但没有找到原因:“tabpage_1”的z-index没有明确设置,而ace编辑器生成的div的最大z-index为4(行号div和光标图层),尝试将div放在编辑器的HTML代码之后。HTML代码是按顺序读取的,最新的元素(如果position:absolute)位于元素之前哪个位置值具有编辑器?选择position:absolute,但编辑器中的position值是多少?可能会显示更多代码必须位于顶部的div(=var标签)确实具有绝对位置,坐标为200px,200px(在addUserCursor函数中设置)。由于此函数还将div附加到编辑器中,因此div的HTML代码已经位于tabscontent HTMLcode的末尾
function addUserCursor(editor, position, user, color) {
var page = document.getElementById("tabscontent");
var label = document.createElement("div");
label.setAttribute("id", editor+"-"+user);
label.setAttribute("position", "absolute");
label.setAttribute("top", "200px");
label.setAttribute("left", "200px");
label.setAttribute("background-color", color);
label.setAttribute("z-index", "10");
label.innerHTML = user;
page.appendChild(label);