Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<head>
<style> 
#container {
  width: 80%;
  aspect-ratio: 4/1;
  border: 1px solid #000000;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  justify-items: space-around; 
}
#container div {
  width: 50%;
  aspect-ratio: 1;
}
</style>
</head>
<body>
<h1>Change justify-items with JavaScript</h1>
<div id="container">
  <div style="background-color:coral;"></div>
  <div style="background-color:lightblue;"></div>
  <div style="background-color:pink;"></div>
</div>
<p>Click the "Try it" button to set the value of the justifyItems property to "center". This makes grid items align center within their own grid cell.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
  document.getElementById("container").style.justifyItems = "center";
}
</script>