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

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -