html - Position a div in the center of a page even if the width and height changes -


<div style="height:100px;width:100px;border:1px solid black"></div> 

how can position div in center?

.parent {   position: relative; }  .child {   width: 300px;   height: 100px;   padding: 20px;    position: absolute;   top: 50%;   left: 50%;    margin: -70px 0 0 -170px; } 

more find here.


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -