Recently I saw that some programmers are using left
and translate
, instead of left
and margin
.
Example below
.container{
width 100%;
border: 1px solid black;
height:300px;
}
.bloco1{
width:50px;
height:50px;
background-color:red;
position:absolute;
left:50%;
transform:translate(-50%, 50%);
}
.bloco2{
width:50px;
height:50px;
background-color:red;
position:absolute;
top:35%;
left:50%;
margin-left:-5%;
}
<div class="container">
<div class="bloco1"></div>
<div class="bloco2"></div>
</div>