I want to position a div at the center of the screen. The issue is when the div is small, from left 45% looks fine but when the div is longer(ie more width), I need to make it from left 30%
Is there a smart way to position the div at the center based on the size of div.
body {
background:blue;
}
.box {
position: absolute;
top:10px;
left:30%;
background:white;
padding:10px;
border-radius:10px;
}
<div class="box">
This is long div so need left = 30 percent
</div>