Background on game page

Recommended Posts


I'm trying to put a background behind the game div in Phaser 3. So that there is my game (960x640) in center of the page and the rest of the page covered with repetitive image


In Phaser 2 I used the following code in my index.html and it worked

.overlay {		
    background: #acbbbe;
    background-image: url(assets/pageBack.png);
    background-repeat: repeat;
    position: absolute; 
    top: 50%; 
    left: 50%; 
    -webkit-transform: translate(-50%, -50%); 
    transform: translate(-50%, -50%);

		<div id="wrapper" class="overlay">
			<div id="gameContainer" class="divstyle"> </div>

Using this snippet together with the following index.js in Phaser 3

const gameConfig = {
	width: 640,
	height: 960,
	scene: SimpleScene,
	parent: 'gameContainer'

new Phaser.Game(gameConfig);

Brings the game div element behind the background div element

What does cause that strange behavior? How can one fix that?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.