Note that there are some explanatory texts on larger screens.

plurals
  1. PO<canvas> within a <div>
    primarykey
    data
    text
    <p>I have a webpage and I am trying to place a canvas inside a set of div tags. However I need the canvas to be on top / a layer above the images within the div. No matter what I try or where I place the canvas html line, I can not get it to work canvas to show above the image in div1.</p> <p>First I define the styles of the div classes.</p> <pre><code>#div1 {width:100%; background:transparent url(img/header-bg.png) no-repeat; height:400px; position:relative;} #div2 {width:100%; background:transparent url(img/nav-bg.png) repeat-x;} #div3 { height:450px; width:100%; position:absolute; background:transparent url(animation/SampleAnim_0010000.png) no-repeat 80% 0; } #div4 { height:390px; width:100%; border-bottom:10px solid rgba(255, 255, 255, 0.5); } </code></pre> <p>Then my html</p> <pre><code>&lt;div id="div1"&gt; &lt;div id="div2"&gt; &lt;div id="div3"&gt; &lt;div id="div4"&gt; &lt;/div&gt;&lt;!--div4--&gt; &lt;/div&gt;&lt;!--div3--&gt; &lt;/div&gt;&lt;!--div2--&gt; &lt;/div&gt;&lt;!--div1--&gt; </code></pre> <p>No matter where I insert within the divs</p> <pre><code>&lt;canvas id="canvas" width="500" height="220"&gt;&lt;/canvas&gt; </code></pre> <p>the image set in id=div1 (img/header-bg.png) overlaps the canvas. div2, div3 and div4 are correctly overlapping div1. How can I do this with the canvas?</p> <p>My canvas script looks something of the lines of</p> <pre><code>&lt;script&gt; var canvas = document.getElementById('canvas'); if(canvas.getContext){ // canvas animation code here: var ctx = canvas.getContext('2d'); var lhs = new Image(); lhs.src = "animation/SampleAnim_0010000.png"; ctx.drawImage(lhs, 0, 0); </code></pre> <p>Any help would be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload