I'm trying to maintain a 2:1 width to height ratio, while trying to maintain the circle elment perfectly aligned vertically and horizontally. By increasing the width, the circled element is not perfectly aligned. Rather than playing with %, is there another way of doing it (and maintaining the 2:1 ratio)?
.con {
display: flex;
border: 2px solid black;
width: 100%;
height:1px;
position: relative;
padding-top: 50%;
}
.a {
width: 50%;
position: absolute;
top: 0;
left: 0;
height: 100%;
background: cyan;
}
.circle {
z-index: 1;
background: green;
border-radius: 50%;
height: 50px;
width: 50px;
margin: auto;
position: absolute;
top: 45%;
bottom: 45%;
left: 45%;
right: 45%;
}
.b {
width: 50%;
position: absolute;
top: 0;
right: 0;
height: 100%;
background: yellow;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div class="con">
<div class="a">A</div>
<div class="circle"></div>
<div class="b">B</div>
</div>
</body>
</html>