html - Why is my css not working? -


I do not know why this CCS text is not working ... should have background color. If someone sees my mistake, Thanks!

I have to add more details, but I think it is not at all obvious, if not only ask! THNX!

  & lt; Html & gt; & Lt; Top & gt; & Lt; Style type = "CSS / text" & gt; #my_canvas {margin: 10; Background color: white; Border: Black 3px solid; } Body {background-color: slategrey; } & Lt; / Style & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Script type = "text / javascript" & gt; Var bg = new image (); Var sh = new image (); Var po = New picture (); Bg.src = "ruimte.jpg"; Sh.src = "schiet.jpg"; Po.src = "pop.gif"; Function canvas () {var ctx = document.getElementById ('my_canvas'). GetContext ('2d'); Var afst = 10; Function background () {this.x = 0, this.y = 0, this.w = bg.width, this.h = bg.height; This.draw = function () {this.x - = 2; Ctx.drawImage (bg, this.x, this.y); If (this.x and lt; = -499) {this.x = 0;}}} function blok () {this.x = 0, this.y = 0, this.w = 40, this.h = 40 , This.color = "orange"; This.draw = function () {//ctx.fillStyle = this.color; //ctx.fillRect(this.x,this.y,this.w,this.h); Ctx.drawImage (po, this.x, this.y); }} Background Background = New Background (); Var blok = new blok (); Function draw () {ctx.save (); Ctx.clearRect (0,0, ctx.canvas.width, ctx.canvas.height); // draw.audraw (); Blok.draw (); Ctx.restore (); } Var animateInterval = setInterval (Draw, 30); Document.addEventListener ('keydown', function (event) {var key_press = String.fromCharCode (event.keyCode); //alert(event.keyCode+ "|" + key_press); if (event.keyCode == 40) {blok .i + = afst} if (event.keyCode == 37) {blok.x - = afst} if (event.keyCode == 39) {blok.x + = afst} if (event.keyCode == 38) { Blok.y - = afst} if (event.keyCode == 32) {warning ("hoy")}}); } Window.addEventListener ('Load', function (event) {canvas (;)}); & Lt; / Script & gt; & Lt; Canvas ID = "my_canvas" width = 1000px "height =" 500px "> Please get a new browser to see the canvas!    < / Pre> 

a CSS / text There is no stylesheet format, so they ignore your stylesheet. You mean text / css .

As HTML5, type attribute Style is optional for elements so it Do not leave completely and you avoid such a mistake.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -