To represent the value as a percentage, adjust the left and top to 50%. This will move the top left corner of the div to the center of the parent element. To ensure that the center of the div is also centered, subtract half of the height and width from the margin (for example, if both were 50px, subtract 25px). See the example below:
css
:
#main{
height: 100vh;
width: 100%;
}
#secondary{
width: 50px;
height: 50px;
top : 50%;
left: 50%;
margin-left: -25px;
margin-top: -25px;
}
For more details, visit my JSFiddle page