javascript-如何将html文本放在画布浮动图表的顶部?

这是我的简单jsFiddle.我希望将HTML文本放置在浮动图表的顶部.或将浮点图放在背景中(取决于您的想法).

HTML:

<div id="wrapper">
  <h1>Place me on top please. How?!</h1>
  <div id="placeholder"></div>
</div>

CSS:

#wrapper { position:relative; }
h1 { z-index:100; color:blue; font-size:5em; margin:0; line-height:0.9em; }
#placeholder {
    width:500px;
    height:300px;
    position:absolute;
    top:0;
    left:0;
    z-index:1;
}

JS(其余请参阅jsFiddle):

$(document).ready(function(){
    chart = $.plot($("#placeholder"),data,options);
});

解决方法:

您应该添加位置:绝对;到您的CSS中的h1 …

Note: z-index only works on positioned elements (position:absolute,
position:relative, or position:fixed).

source of this quoted text

#wrapper { position:relative; }
h1 { z-index:100; color:blue; position: absolute; font-size:5em; margin:0; line-height:0.9em; }
#placeholder {
    width:500px;
    height:300px;
    position:absolute;
    top:0;
    left:0;
    z-index:1;
}

:::: JSFIDDLE ::::

上一篇:javascript-在单个浮点图上显示点的数据集和线的数据集?


下一篇:javascript-如何检查JSON数组是否等于