Это просто простая математика ...
w - width of the small image
W - width of the big image
l - left position of the small image
L - left position of the big image
L = l + 1/2w - 1/2W
h - height of the small image
H - height of the big image
t - top position of the small image
T - top position of the big image
T = t + 1/2h - 1/2H
Итак, предположим, что наше изображение:
<img style="width:221px; height:221px; position:absolute; left:600px; top:700px;" />
Ответ:
Left = 600 + 1/2*221 - 1/2*1000 = 210 (rounded)
Top = 700 + 1/2*221 - 1/2*1000 = 310 (rounded)
<img style="width:1000px; height:1000px; position:absolute; left:210px; top:310px;" />
Используя этот расчет, вы можете определить, где вам нужно разместить большое изображение / div для центрирования относительно другого объекта.
Edit:
Чтобы собрать все вместе, предполагая, что bigImage - это РЕБЕНОК области просмотра, вам нужно использовать 0 как t и 0 как l.
Left = 0 + 1/2*221 - 1/2*1000 = -390 (rounded)
Top = 0 + 1/2*221 - 1/2*1000 = -390 (rounded)
<div id="viewport" style="width:221px; height:221px;overflow:hidden;position:relative;">
<img id="bigImage" style="width:1000px; height:1000px; position:absolute; left:-390px; top:-390px;" />
</div>
- как вы видите, я использовал отрицательные значения, поэтому bigImage будет прятаться за окном просмотра и потому.