I am aiming to create a layout similar to the image displayed below.https://i.sstatic.net/Q5n8J.png
To be more specific, my goal is to scatter smiley faces randomly within a 500px area while also having a border on the right side of the area.
However, with the current code I'm using, I'm not achieving the desired outcome.
<!DOCTYPE html>
<html>
<head>
<style>
img {
position: absolute
}
div {
width: 500px;
height: 500px
}
#rightSide {
position: absolute;
left: 500px;
border-left: 1px solid black
}
</style>
</head>
<body onload="generateFaces()">
<div id="leftSide"></div>
<div id="rightSide"></div>
<script>
var numberOfFaces = 5;
var top_position = 400;
var left_position = 400;
var theLeftSide = document.getElementById("leftSide");
var i = 0;
function generateFaces() {
while (i < numberOfFaces) {
var this_img = document.createElement("img");
this_img.src = "#";
this_img.style.top = top_position + "px";
this_img.style.left = left_position + "px";
theLeftSide.appendChild(this_img);
top_position = top_position - 50;
left_position = left_position - 50;
i++;
}
}
</script>
</body>
</html>
The output I am currently getting from the provided code snippet appears likehttps://i.sstatic.net/aG1ET.png
What steps should I take to correct this?