With position: relative on the surrounding items and pixel positioning, you're not going to get a responsive layout.
First, with position: relative, the element is positioned relative to its original position, not the center circle. This results in a misalignment.
Second, a positioned element with top: -670px; left: 650px; may look okay on wider screens, but is way outside the viewport on smaller screens. This also messes up your alignment.
Instead, remove the surrounding items from the normal flow with position: absolute, make them relative to their container (with position: relative), and use percentage lengths for adaptability.
revised codepen
$(document).ready(function() {
$(".subOne").hide();
$(".subTwo").hide();
$(".subThree").hide();
$(".subFour").hide();
$(".mainCircle").bind('click', function() {
$(this).toggleClass('blue');
$(".subOne").slideToggle('fast');
$(".subTwo").slideToggle('fast');
$(".subThree").slideToggle('fast');
$(".subFour").slideToggle('fast');
});
});
body {
margin: 0;
}
.container {
position: relative;
}
.subContainer {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
background: coral;
}
.mainCircle,
.subOne,
.subTwo,
.subThree,
.subFour {
border: 2px red solid;
height: 100px;
width: 100px;
border-radius: 100px;
background: blue;
transition: 0.3s ease all;
}
.subOne {
position: absolute;
top: 20%;
left: 50%;
transform: translate(-50%, -50%); /* see link below for explanation */
}
.subTwo {
position: absolute;
bottom: 20%;
left: 50%;
transform: translate(-50%, 50%);
}
.subThree {
position: absolute;
top: 50%;
left: 20%;
transform: translate(-50%, -50%);
}
.subFour {
position: absolute;
top: 50%;
right: 20%;
transform: translate(50%, -50%);
}
.mainCircle:hover {
background: lightblue;
transition: 0.3s ease all;
}
.blue {
border: 10px black solid;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container">
<div class="subContainer">
<div class="mainCircle"></div>
</div>
<div class="subOne"></div>
<div class="subTwo"></div>
<div class="subThree"></div>
<div class="subFour"></div>
</div>
More details: Element will not stay centered, especially when re-sizing screen