这是我的简单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).
#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;
}