html - Centering an absolute positioned div -


i need center div wrapped inside div:

div centered:

.post-username {     padding: 10px;     background: #000;     border-radius: 4px;     position: absolute;     top: 0; } 

it should centered inside of this:

.post {     background: #3e4758;     overflow: hidden;     border-radius: 4px;     width: 270px;     height: 330px;     position: relative; } 

.post-username {     padding: 50px;     background: #000;     border-radius: 4px;     position: absolute;     top: 50%;     left: 50%;     transform: translate(-50%, -50%);     -webkit-transform: translate(-50%, -50%);     -moz-transform: translate(-50%, -50%); }  .post {     background: #3e4758;     overflow: hidden;     border-radius: 4px;     width: 270px;     height: 330px;     position: relative; } 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -