HTML5 Canvas & z-index issue in Google Chrome

HTMLWeb DevelopmentFront End Technology

When we apply z index to a canvas whose position is fixed, it stop causes chrome to render all other elements which have position:fixed properly. This only happens if canvas is greater than 256X256 px in size.

Wrap both h1 and canvas with the fixed div and solves the issue −

<div id = 'fixcontainer'>
   <h1>Test Title</h1>
   <canvas id = "backgroundCanvas" width = "1000" height = "300"></canvas>
</div>

The following is the CSS −

h1{
   position: fixed;
}
body{
   height: 1500px;
}
canvas{
   position: fixed; z-index: -10;
}
raja
Published on 21-Mar-2018 14:06:22
Advertisements