简体   繁体   English

在div w3-row / w3-col(W3CSS)上方显示画布

[英]Display canvas above div w3-row/w3-col (W3CSS)

So I'm using w3-css to create a layout for my application but the application includes a canvas. 因此,我正在使用w3-css为我的应用程序创建布局,但该应用程序包含画布。 The canvas that I use right now is being hidden by the div above it. 我现在使用的画布被其上方的div隐藏。

I honestly have no clue how to fix this. 老实说,我不知道如何解决这个问题。

Only thing I could think of and find is Z-index but it wouldn't work to change it. 我唯一能想到并找到的就是Z-index,但是更改它是行不通的。

An example of my problem is in this jsfiddle: 我的问题的一个示例在此jsfiddle中:

https://jsfiddle.net/L8frrcfr/ https://jsfiddle.net/L8frrcfr/

<div class="w3-row">
  <div class="w3-col m6 w3-gray">
     <canvas width="100" height="100"></canvas>
  </div>
  <div class="w3-col m6 w3-light-blue" style="height: 100px;">

  </div>
</div>

As you can see the content in the w3-cols display above the canvas. 如您所见,画布上方的w3-cols显示内容。 I want the canvas to be above the w3-col. 我希望画布在w3-col上方。

That is not true. 那是不对的。 If you fill the canvas (default transparent!), you will see that it is rendered on top: 如果您填充画布(默认为透明!),您将看到它在顶部渲染:

https://jsfiddle.net/ibowankenobi/L8frrcfr/2/ https://jsfiddle.net/ibowankenobi/L8frrcfr/2/

var context = document.getElementsByTagName("canvas")[0].getContext("2d");
context.fillStyle = "#ff0000";
context.fillRect(0,0,100,100)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM