我有一个带有背景图片的画布,代码如下。如何用css将背景图像带到前面?图像应该出现在画布前面。
.dvContainer {
opacity: .7;
z-index:-100;
}
.background {
background-repeat: no-repeat;
background-image:url(https://i.imgur.com/ITWfejd.png);
background-position: center;
}
<div>
<canvas id="myCanvas" class="dvContainer background" width="400" height="300"
style="background-color: red;">
</canvas>
</div>
答案 0 :(得分:0)
这样做: -
.dvContainer {
opacity: .7;
z-index:1001;
display:none;
}
.background {
background-repeat: no-repeat;
background-image:url(https://i.imgur.com/ITWfejd.png);
background-position: center;
}
<div>
<canvas id="myCanvas" class="dvContainer background" width="400" height="300"
style="background-color: red;">
</canvas>
</div>
并将Div Element
放在页面顶部。
如果没有发生,这将在顶部找到div尝试增加z-index