1
votes

My code:

let div1 = document.createElement('div');
div1.style = 'background-color: lime; width: 220px; height: 100px; font: 48px Arial; font-weight: bold';
div1.innerText = 'Phaser 3';
this.add.dom(300, 0, div1);

I'm trying to add a div with text-element. Everything is ok, but text isn't visible. What's the matter?

1

1 Answers

2
votes

Your y value is too low. You are successfully adding the div element to your DOM but it's adding it at an y coordinate of 0 so you can't see the full element.

Try changing to this:

this.add.dom(300, 200, div1);