HTML5キャンバス要素で動的な背景を作成することが可能かどうかについて、さまざまな証拠があります。ここでは正常に行われているようだ男だ:キャンバスの背景がアンカーを解除不可にする
http://radikalfx.com/files/anibg/
私は背景として私のcanvas要素を首尾よく配置されているが、それはunclickable私のリンクをレンダリングしています。ここでは状況があります:
HTML:
<div id='container'>
... other header stuff ...
<canvas id='background'>
</canvas>
<!-- Can't touch this *MC Hammer Shuffle* -->
<a href='#'>test</a>
... footer stuff ...
</div>
CSS:
/* Everything's z-index is now 1 */
#container
{
position: relative;
min-height:100%;
width:100%;
z-index:1;
}
/* Make the canvas z-index 0 */
#background
{
position: absolute;
top: 0;
width:100%;
height:100%;
z-index: 0;
}
はJavaScript:
// Onload Draw an ellipse
// I've got jCanvas installed (jQuery plugin) to use the drawArc() method
// This bit can be replaced with whatever test code you want.
function load()
{
init_canvas();
$("canvas").drawArc({
fillStyle: "black",
x: 100, y: 100,
radius: 50
});
}
// Make the canvas the appropriate size
function init_canvas()
{
canvas = document.getElementById("background");
canvas.width = document.width;
canvas.height = document.height;
canvasW = canvas.width;
canvasH = canvas.height;
}
乾杯!
エラーが発生します。*未知の型エラー:オブジェクト[オブジェクト]にはメソッド 'drawArc' *がありません。 '$()'はjQueryオブジェクトを返します(jQueryを使用している場合)。 –
キャンバスを背景に設定する必要がある特定の方法はありますか?私はそれをやっているように感じています。適切な実装ではなく、回避策です。 – PandemoniumSyndicate
@FelixKling jCanvasがインストールされていますか?これは私が与えたサンプルのものを使うのに必要なAPIの一部です。投稿を編集して – PandemoniumSyndicate