Et eksempel:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="content-type" content="text/html; charset=iso-8859-1"><title>Ingen titel</title>
<style type="text/css">
#cdiv{
background:#00f;
position:relative;
height:300px;
width:350px;
}
#cbil{
background:#0ff;
position:absolute;
left:50%;
top:50%;
margin-left:-145px;
margin-top:-109px;
}
</style>
<script type="text/javascript">
var cbil;
window.onload=function(){
cbil=document.getElementById("cbil");
cbil.onload=function(){calign();};
}
function cpic(tmpp){
cbil.src=tmpp;
}
function calign(){
cbil.style.marginLeft=(cbil.offsetWidth/2*-1)+"px";
cbil.style.marginTop=(cbil.offsetHeight/2*-1)+"px";
}
</script>
</head><body>
Baseret på start billede cbil er 290x218 px derfor halvdelen i negativ padding på begge top og left i margin
<div id="cdiv"><img src="b1.jpg" id="cbil"></div>
<b onclick="cpic('b1.jpg');">Skift billedet til b1.jpg</b><br>
<b onclick="cpic('./b2.jpg');">Skift billedet til b2.jpg - f.eks. 150 x 100px</b>
</body></html>
... hjalp det ?