Используйте следующий процесс:
- ширина на основе Процентное соотношение и высота для всех не
img
элементов
250px
для ширины и высоты img
элемент (ы)
display:inline-block;
и text-align:center
для горизонтального центрирования
125px
для верхнего и нижнего края img
<!doctype html>
<html lang="en">
<head>
<style type="text/css">
/*Set dimensions of image in CSS */
img { width:250px; height:250px; margin: 125px 0; }
/* Use inline-block for wrapper and placeholder */
.placeholder, .wrapper { display: inline-block; }
/* Inline necessary to use text-align:center */
.content { display:inline; }
/* Text align for horizontal centering */
.container { text-align:center; }
.wrapper { width: 100%; }
</style>
<title>Vertical/Horizontal Centering Test</title>
</head>
<body>
<div class="container">
<div class="content">
<div class="wrapper">
<img src="http://mozilla.com/favicon.ico" alt="test image">
</div>
</div>
<span class="placeholder"></span>
</div>
</body>
</html>