Фон в Предложении

const buttons = document.querySelectorAll('button');
const display = document.querySelector('.display');

buttons.forEach(function(button) {
  button.addEventListener('click', calculate);
});

function calculate(event) {
  const clickedButtonValue = event.target.value;

  if (clickedButtonValue === '=') {  
    if (display.value !== '') {
      let str = display.value
        .replace(/\^/g, "**")
        .replace(/%(\d+(?:\.\d+)?)/g, "*($1/100)");        
        
      display.value = eval( str );
    }    
  } else if (clickedButtonValue === 'C') {  
    display.value = '';
  } else {
    display.value += clickedButtonValue;
  }
  
  
}
function soundClick() {
  var audio = new Audio(); 
  audio.src = 'https://www.myinstants.com//media/sounds/10_p895CLI.mp3'; 
  audio.autoplay = true; 
}
function soundClick2() {
  var audio = new Audio(); 
  audio.src = 'https://www.myinstants.com//media/sounds/0447-mp3cut.mp3'; 
  audio.autoplay = true; }
  const s = window.screen;
  
const w = (q.width = s.width);
const h = (q.height = s.height);
const ctx = q.getContext("2d");

const p = Array(Math.floor(w / 10) + 1).fill(0);

const random = (items) => items[Math.floor(Math.random() * items.length)];

const hex = "0123456789ABCDEF".split("");

setInterval(() => {
  ctx.fillStyle = "rgba(0,0,0,.05)";
  ctx.fillRect(0, 0, w, h);
  ctx.fillStyle = "#0f0";
  p.map((v, i) => {
    ctx.fillText(random(hex), i * 10, v);
    p[i] = v >= h || v > 50 + 10000 * Math.random() ? 0 : v + 10;
  });
}, 1000 / 30);
* {
  padding: 0;
  margin: 0;
}

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #222831;
  font-family: sans-serif;
    margin: 0;
    overflow: hidden;
  
}

.calculator {
  width: 300px;
  padding-bottom: 15px;
  border-radius: 7px;
  background-color: rgb(0, 0, 0);
  box-shadow: 5px 8px 8px -2px rgba(0, 0, 0, 0.61);
  
}

.display {
  width: 100%;
  height: 80px;
  border: none;
  box-sizing: border-box;
  padding: 10px;
  font-size: 2rem;
  background-color: #f8d407;
  color: rgb(0, 0, 0);
  text-align: right;
  border-top-left-radius: 7px;
  border-top-right-radius: 7px;
 
  
}

.row {
  display: flex;
  justify-content: space-between;
}

button {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  outline: none;
  font-size: 1.5rem;
  background-color: rgb(34, 34, 34);
  color: #fff;
  margin: 10px;
}

button:hover {
  cursor: pointer;
}

.operator {
  background-color: #888888;
  color: rgb(0, 0, 0);
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" type="text/css" href="css/styles.css">
  <title>Calculator</title>
  <canvas id=q></canvas>
    
</head>

<body>

  

  <div class="calculator">

    

    <input type="text" class="display" disabled>

    

    <div class="keys">

      

      <div class="row">
        <p onclick="soundClick2()"><button value="7">7</button></p>
        <p onclick="soundClick2()"><button value="8">8</button></p>
        <p onclick="soundClick2()"><button value="9">9</button></p>
        <p onclick="soundClick2()"><button value="+">+</button></p>
      </div>
      <div class="row">
        <p onclick="soundClick2()"><button value="4">4</button></p>
        <p onclick="soundClick2()"><button value="5">5</button></p>
        <p onclick="soundClick2()"><button value="6">6</button></p>
        <p onclick="soundClick2()"><button value="-">-</button></p>
      </div>
      <div class="row">
        <p onclick="soundClick2()"><button value="1">1</button></p>
        <p onclick="soundClick2()"><button value="2">2</button></p>
        <p onclick="soundClick2()"><button value="3">3</button></p>
        <p onclick="soundClick2()"><button value="*">*</button></p>
      </div>
      <div class="row">
        <p onclick="soundClick2()"><button value="C">C</button></p>
        <p onclick="soundClick2()"><button value="0">0</button></p>
        <p onclick="soundClick2()"><button value="/">/</button></p>
        <p onclick="soundClick()"><button value="=" class="operator">=</button></p>    
      </div>
      <div class="row">
        <p onclick="soundClick2()"><button value="(">(</button></p>
        <p onclick="soundClick2()"><button value=")">)</button></p>
        <p onclick="soundClick2()"><button value="^">^</button></p>
        <p onclick="soundClick2()"><button value="%">%</button></p>
      </div>
    </div>

  </div>

  


  <script type="text/javascript" src="js/scripts.js"></script>
</body>

</html>

Здравствуйте, хочу добавить фон к калькулятору, но когда добавляю, калькулятор перемешается вправо, а мне надо чтобы он был посредине, а сзади фон


Ответы (0 шт):