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
Post a Comment