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;
}
#container div {
  width: 50%;
  aspect-ratio: 1;
}
</style>
</head>
<body>
<h1>Change justify-self with JavaScript</h1>
<div id="container">
  <div style="background-color:coral;"></div>
  <div id="blue" style="background-color:lightblue;"></div>
  <div style="background-color:pink;"></div>
</div>
<p>Click the "Try it" button to set the value of the justifySelf property to "right". This makes the blue grid item align right within its own grid cell.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
  document.getElementById("blue").style.justifySelf = "right";
}
</script>
</body>