What is the best way to eliminate the default background color applied to the body automatically?

I'm currently developing a Covid-19 tracking web application and I am using chartJS to showcase data from an API. In my CSS, I have assigned a background color to all elements with an asterisk (*), but for some reason there are empty spaces around the Canvas element. Upon inspecting it in Chrome, I noticed that a white background color is being automatically applied to the body, which I did not specify. How can I remove this auto-applied background color? Thank you in advance. :)

https://i.sstatic.net/TqlGP.png

JS CODE

var ctx = document.getElementById('myChart').getContext('2d');
    let myChart = new Chart(ctx, {
      type: 'line',
      data: {
        labels: date,
        datasets: [
          {
            label: 'Total',
            data: total,
            borderColor: '#cf0000',
            fill: false,
          },
          {
            label: 'Recovered',
            data: recovered,
            borderColor: '#4ca1a3',
            fill: false,
          },
          {
            label: 'Deaths',
            data: deaths,
            borderColor: '#907fa4',
            fill: false,
          },

HTML CODE

 <div class="container">
        <h1 class="text-center mt-3 heading">COVID-19 Tracker</h1>
        <canvas id="myChart"></canvas>
    </div>

CSS

    * {
    margin: 0;
    padding: 0;
    background-color: #e7d4b5;
}

Answer №1

Include CSS in your code and make the background color transparent.

body{
   background-color: transparent;
}

Answer №2

Modified

<div class="wrapper"> -> <div class="container-fluid">

Additionally, the blank areas with a white backdrop are now replaced with the specified background color.

This appears to be related more to the Bootstrap aspect of the issue. Upon switching the class to container-fluid, the graph expanded to cover the entire screen. To adjust for this, I included padding around the graph for some spacing.

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

Tips for converting JSON information on a website and inserting it into a designated division?

I've recently delved into front-end development, searching for solutions and hints without much success. I'm currently in the process of building my first website, specifically a "find recipes" website. Lacking knowledge of API calls, I created a ...

Tips for successfully sending data to an ng-include controller

So, I've got this ng-include html element, and I'm trying to figure out how to pass data from an external source to the controller. The primary controller is responsible for fetching json data from a http webservice, and then parsing that data i ...

Discovering the most cost-effective combination algorithm

Looking for two numbers, P and Q, in a given array N with at least 5 items where 0 < P < Q < N - 1. Consider the following array: const N = [1, 9, 4, 5, 8]; If P = 1 , Q = 2 , then the cost is N[P] + N[Q] = N[1] + N[2] = 9 + 4 = 13 If P = 1, Q ...

Removing the Arrow on a Number Input Field Using Tailwind CSS

Is there a way to remove the default increment/decrement arrows that come with an input of type number using Tailwind CSS? I've searched for a solution but haven't found one yet. input type="number" placeholder="Phone number" className="border ...

My Next.js application does not display an error message when the input field is not valid

I've recently developed a currency converter application. It functions properly when a number is provided as input. However, in cases where the user enters anything other than a number or leaves the input field empty, the app fails to respond. I aim t ...

Using webGL for rendering drawElements

I am working with face-indices that point to specific points to draw triangles in a loop. Unfortunately, when executing my code, I encountered the following error in the web console: WebGL: drawElements: bound element array buffer is too small for given c ...

Looking to subtly transition from the current webpage to the next one with a fading effect?

I'm looking to create a smooth transition between web pages on my site by slowly fading out the current page and fading in the next one when a link is clicked. $(document).ready(function() { $('body').css("display","none"); $(&a ...

Struggling to locate __proto__ of the global object known as "window."

Currently I am using Google Chrome browser. console.log(window.__proto__.__proto__.__proto__); console.log(window.__proto__.__proto__.__proto__ === EventTarget.prototype); The first code mentioned above returns EventTarget.prototype for me. This can be ...

Creating a variable in Node.js to serve as the name of a nested element within an object

Check out the object I have: obj = { "FirstName": "Fawad", "LastName": "Surosh", "Education": {"University": "ABC", "Year": "2012"} } Take a look at my node.js script: var nodeName = 'Education.Year'; obj.nodeName; // ...

"Error: The chai testing method appears to be improperly defined and is not

I am trying to set up a Mocha and Chai test. Here is my class, myClass.js: export default class Myclass { constructor() {} sayhello() { return 'hello'; }; } Along with a test file, test.myclass.js: I am attempting to a ...

Manipulate jQuery to set the table row containing empty table data cells to be lower than the row with

I am using HTML and jQuery to sort my table, including non-standard sorting with multi-tbody. The issue I am facing is that the prices (Цена) in the td are sorted ascending but not correctly. Why is this happening? Additionally, I need to move the tr&a ...

Utilizing JavaScript to assign object properties (column names) from an Array of Objects to a specific row and column header

I am currently in the process of implementing a mapping function to display data from an array of objects, initially stored in localStorage, into a table using Material-UI Table. The goal is to map all the specific column names into corresponding Table Ce ...

"Addclass() function successfully executing in the console, yet encountering issues within the script execution

I dynamically created a div and attempted to add the class 'expanded' using jQuery, but it's not working. Interestingly, when I try the same code in the console, it works perfectly. The code looks like this: appending element name var men ...

Is there a way to serialize a dynamically loaded element with jQuery?

So here's the situation: I have a list of tags that needs to be updated using an ajax call. First, I clear out the <ul> that holds the tags. Then, with the response from the ajax call, I populate the <ul> with new <li> elements re ...

Data in DynamoDB Local is deleted once the instance is shut down

My app is utilizing DynamoDB Local and I am facing an issue where it keeps deleting all the sample data each time I shut down the instance. This problem seems to be unique as I have not found any similar cases while searching for a solution. I typically ...

When the NODE_ENV is set to 'production', the global error handler middleware fails to log errors

To ensure proper code format, errors are logged and returned to the client using Postman in development mode, but are not sent back to the client in production mode. The following code represents the global error handler: module.exports = (err, req, res, n ...

Drop your friend a line, I'm curious about the Javascript API

As a developer hailing from the Republic of Korea, I am currently in the process of creating websites that are based on Facebook and Twitter. I am interested in utilizing a JavaScript API that allows me to send messages to friends. Initially, I considered ...

Tips on customizing styles for Material UI components using CSS override techniques

Currently, I am tackling a project that requires the use of Material UI components. To simplify things, let's focus on a basic functional component that includes two Material UI elements: a Button and a Text Field. import React from 'react'; ...

Transfer elements from collections employing multer

Data Payload Example:- education[0][university]: jru education[0][degree]: mca education[0][specialization]: computer application education[0][certificate_pdf_url]: (binary) education[0][degree_type]: Teaching Degree education[0][years_of_study]: [&q ...

Interacting with the DOM of an iFrame from a separate window using Javascript

My main webpage is hosted on "DomainA" and it contains an iFrame sourced from "DomainB". Within this iFrame, there is a click event that opens a new window, also sourced from "DomainB". I am attempting to update an input field within the iFrame from the n ...