I have a div filling all the width and an amount of the height, and then I have an smaller circle which needs to be half on the bottom/center of this div, half right after it.
All works until I got more height or try to zoom it, then the circle will just move vertically and no longer being 50/50. Also, zooming the page will make the circle expand from its top, not its middle.
<div id="rectangle">
<img id="circle" src="http://alloutput.com/wp-content/uploads/2013/11/black-circle-mask-to-fill-compass-outline.png">
</div>
Css:
body {
position: absolute;
width: 100%;
height: 100%;
top: 0px;
left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
#rectangle {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 92%;
background: #E5E5E5;
}
#circle {
position: absolute;
top: 86%;
left: 0;
right: 0;
width: 100px;
margin-right: auto;
margin-left: auto;
}
Since circle is inside the rectangle, than its position is relative to rectangle. That means you need to set the circle
bottom
property to half of circle radius:I used html element to create a circle instead of the image you provided (you may delete it).