Ok so i have one div and inside it a canvas: my html file:
<div id="container">
<canvas id="game" width="600px" height="2000px">
</div>
my css file:
#game{
background: -moz-linear-gradient(top, #00b7ea0%, #008793 14%, #04b9b 43%, #1f00ea 74%, #008793 89%, #009ec3 100%);
bottom: 0px;
position: absolute;
}
#container{
position: relative;
width:600px;
height:500px;
}
And here is my question: What code should be used in a javascript file, if i want to control the bottom property of #game?
What i mean i that i want the user to press a botton, e.g. W(=87), and the bottom property to change negative or possitive direction is irrelevant, the need is to make a code that when a key is pressed the magnitude of the bottom property will change.
I hope that i described the probel well, if more info is needed please ask... Looking forward for a reply :-)
canvas's but I would assume it's the same as any other tag. You can refer to the style property:document.getElementById('game').style.bottom = "20px";. There is a little more to it. You would need to get the existing value. You can parse it withparseInt(), then increment or decrement as needed, then set the value.onkeyup,onkeypress, andonkeydown. They each have slightly different uses and event return values.