###前提・実現したいこと
canvasでアニメーションを作ってそれを背景にしたいです。
今の状態だと、テキストを上に重ねることができないです。
###該当のソースコード
HTML
1 window.onload = function(){ 2 const cvsw = 1500; // canvasタグに指定したwidth 3 const cvsh = 800; 4 const imgsize = 125; // canvasタグに指定したheight 5 const srcs = ["images/reaf.png","images/reaf.png","images/reaf2.png","images/reaf2.png", "images/reaf3.png","images/reaf3.png"]; 6 const canvas = document.getElementById('cvs'); 7 const ctx = canvas.getContext('2d'); 8 const images = srcs.map(function(src, index){ 9 const image = new Image(); 10 image.src = src; 11 return { image, x: Math.random()*cvsw, y:0, index }; 12 }); 13 for(const image of images){ 14 image.onload = setInterval(function(){ 15 if(image.y >= 800-120) 16 return; 17 if(image.index == 0) 18 ctx.clearRect(0,0,cvsw,cvsh); 19 ctx.drawImage(image.image, image.x, image.y, 125, 125); 20 image.y += 1 21 },19); 22 23 } 24 } 25 </script> 26
CSS
1/*body*/ 2body #wrapper{ 3 width: 100%; 4 height:100%; 5 min-height:100%; 6 overflow: hidden; 7 position: fixed;} 8body{ 9 width:100%; 10 margin: 0; 11 padding: 0; 12} 13body #wrapper{ 14 width: 100%; 15 height:100%; 16 min-height:100%; 17 overflow: hidden; 18 position: fixed; 19 } 20#container { 21 background: 22 position: absolute; 23 top:0; 24 right:20px; 25 left:20px; 26 } 27 28
よろしくお願いします。
回答が付いた質問の編集は慎重に行ってください。質問文のコードについて回答にて指摘があった場合は「追記」し、元のコードを編集する場合も「直したこと」がわかるようにしてください。