The background image spanning across the entire screen, not just confined to the center

view image details here Can anyone explain why my background image for the main game is displaying like this? I want to set it for the entire screen as I have different backgrounds planned for the menu of the game and the game itself. Any suggestions to make my work easier would be greatly appreciated. Thank you.

*,
::before,
::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Skranji', sans-serif;
}


/* Root Styles */

:root {
  --background-main-game: url('../images/wowWP.jpg');
  --background-main-menu: url('../images/gameMenu.jpg');
}

main {
  height: 100vh;
}


/* Game Background */

.mainGameBackground {
  background-image: var(--background-main-game);
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  position: relative;
  height: 100vh;
  width: 100vh;
}
<section class="mainGameBackground">
  <!-- Game board -->
  <div class="gameBoard">
    <div class="mainBoard mt-0 mb-5 text-center mx-auto" id="mainGameBoard">
      <span id="warriorTurn"></span>
      <div class="square square1" style="border-left: 0; border-top: 0; margin-left: 15px;" id="0"></div>
      <div class="square square2" style="border-top: 0" id="1"></div>
      <div class="square square3" style="border-top: 0; border-right: 0;" id="2"></div>
      <div class="square square4" style="border-left: 0; margin-left: 15px;" id="3"></div>
      <div class="square square5" id="4"></div>
      <div class="square square6" style="border-right: 0;" id="5"></div>
      <div class="square square7" style="border-left: 0; border-bottom: 0; margin-left: 15px;" id="6"></div>
      <div class="square square8" style="border-bottom: 0;" id="7"></div>
      <div class="square square9" style="border-right: 0; border-bottom: 0;" id="8"></div>
    </div>
    <div class="d-md-flex">
      <button class="btn d-block mb-4 m-md-1" id="playAgain">Play Again</button>
      <button class="btn d-block ml-md-4 m-md-1" id="menuButton">Menu</button>
    </div>
  </div>
</section>

Answer №1

Important Notice: Your image currently has a white background which is affecting its appearance. To improve this, you need to adjust the width to 100% as shown below:

.mainGameBackground {
  background-image: var(--background-main-game);
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  position: relative;
  height: 100vh;
  width: 100%; /* Make sure to use percentage for width */

}

Please consider changing the image or removing the white background.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Text in d3.js vanishing while undergoing rotation

I have been struggling for hours with what seems like a simple problem and haven't made any progress. I'm hoping to receive some valuable advice from the brilliant minds on stackoverflow. You can view my demo at I attempted to use jsfiddle to s ...

Retrieve the file path of the local system's home directory from the server

The server is up and running, I am looking to retrieve the file path of the local system in which the AWS server is operating using Node.js. ...

Creating a dynamic image gallery in Handlebars using Express

I have successfully implemented handlebars with puppeteer to generate a PDF server-side and save it in my database. However, I am facing an issue with loading images stored in an assets directory through the img tag. In my index.js file, I have a helper c ...

Maintain HOVER State in CSS Drop Down Menu upon Clicking

I have implemented a CSS Drop Down Menu on my website. In a specific section of the site, I am using the menu links to trigger AJAX-jQuery calls that dynamically change the content of a DIV without the need for page reloading. <script type="text/javasc ...

What is causing the data in the hierarchy table to be invisible?

I am attempting to build a hierarchical table using Vue.js as the foundation. However, I want the table to remain hidden with no data displayed. The issue seems to be within this section of code: <tr v-if="item.childrenVisible" v-for="chi ...

selection menu and advancement gauge

While working on my code, I have a task where I need to make the progress bar move a specific amount when a name is clicked based on the option's value. <!DOCTYPE html> <html> <head> <title>testinggg</title> &l ...

Express: SimpleAuth

I've been attempting to set up basic authorization for the endpoints in my express app using express-basic-auth, but I keep getting a 401 unauthorized error. It seems like the headers I'm sending in Postman might be incorrect: Middleware: app.u ...

problem of keeping behat/selenium browser open after execution

I am attempting to execute the behat/selenium test with Chrome browser by running the following feature scenario. I would like to keep the browser window open instead of closing the Chrome immediately. Even though I have implemented the iWaitForSeconds ste ...

Placing a crimson asterisk beside the input field within Bootstrap

Trying to insert a red * at the end of my input field using bootstrap, but all my attempts so far have been unsuccessful. Is there a way to align the Currently experiencing this issue: https://i.stack.imgur.com/61pzb.png Code snippet: .required-after ...

What is the best way to swap out text for an image in CSS?

I came across a website that I am working on: The site features a slider with 2 tabs named "TAB1" and "tab2" My goal is to replace the text with unique images for each tab Below is the CSS code snippet: .dnd-tabs.dnd-tabs-style1 .ui-tabs-nav li.ui-tabs ...

Error occurs when attempting to instantiate a class with parameters that do not match any available constructor signatures

I am attempting to encapsulate each instance of router.navigateByUrl within a class function, with the intention of calling that function in the appropriate context. However, I am encountering an error that states 'Supplied parameters do not match any ...

Having difficulty properly streaming UI components with Vercel's AI-SDK

Recently, I've been diving into the new Vercel's AI-SDK to expand my skills. My current project involves developing a persona generator that takes specific guidelines as inputs and generates persona attributes according to a given Zod schema. B ...

Utilizing IISNode and/or nodemon for efficient node.js development on Windows platform

For my node.js application running on Windows, I currently utilize IISNode both locally during development and on production hosting. Would incorporating nodemon (or a comparable module that monitors file changes and restarts node.exe when necessary) pro ...

Purpose of triggering another function during an ajax request

I have encountered an issue while working on a project. There is a page with an input field called balance within a div named balanceDiv. This field should not be visible to the admin, so I used ng-show to hide/show the div based on the user's login I ...

Utilize Mongo's $facet feature to retrieve and calculate the number of tags associated with the products that have been

My current aggregation pipeline looks like this: aggregate.lookup({ from: 'tags', localField: 'tags', foreignField: '_id', as: 'tags' }); aggregate.match({ productType: 'prod ...

Exploring the capabilities of soup.find() for achieving partial matches

I've been struggling to find an answer to this issue elsewhere, so I'm turning to this code: soup.find(text="Dimensions").find_next().text to extract the text after "Dimensions". The problem arises on the website I'm scraping beca ...

Can you show me the steps for downloading the WebPage component?

My goal is to save webpages offline for future use, but when I download them as html many of the included components disappear! I attempted opening them in a WebBrowser and downloading as html with no success. One potential solution is to download the ht ...

Unexpected behavior in VueJS code - troubleshooting the issue

In my VueJs code, I have a simple task list with completed and incomplete tasks. When I check or uncheck the box, the task should move to the appropriate list. var app = new Vue({ el: '#vueapp', data: { tasks: [{ id: 1, ...

When you press the submit button, the screen automatically scrolls down but no action is taken

I'm currently utilizing Selenium WebDriver (Java) with the Firefox driver. Upon trying to click the 'Submit' button on a particular page, it only results in scrolling down the screen slightly. The button itself does not register the click, c ...

Emphasizing the text while making edits to an item within the dhtmlx tree

Whenever I need the user to rename an item on the tree, I trigger the editor for them: tree.editItem(tree.getSelectedItemId()); However, I want the text in the editor to be automatically selected (highlighted). Currently, the cursor is placed at the end ...