How to remove automatically applied background color to the body?

Viewed 88

I'm working on a Covid-19 tracking web app and utilizing chartJS to display data from an API. Applied background color to * in CSS but somehow there are empty spaces around the Canvas. I inspected it on Chrome, and somehow background color of white is applied to the body, which I never wrote. How to remove this automatically applied background color? Thank you in advance. :)

Inspection on Google Chrome

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;
}
2 Answers

Add some CSS to your code and set the background color to transparent.

body{
   background-color: transparent;
}

Changed

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

and the side spaces with white background are filled with the background color that I wrote.

I guess it was more on the Bootstrap side of the problem. After changing the class to container-fluid, the chart stretched to fill the screen, so I added padding to the chart to have some spaces.

Related