I have a dynamic image that appears when an icon is clicked to overlay the image to display it. It shows, but off center.
$('.preview').click(function(){
var img = $(this);
$("#<%=imgFull.ClientID%>").attr("src", img.attr('fullImg'));
$("#<%=imgFull.ClientID%>").attr("top", "50%");
$("#<%=imgFull.ClientID%>").attr("left", "50%");
$("#<%=imgFull.ClientID%>").attr("margin-top", "-" + (img.width()) + "px");
$("#<%=imgFull.ClientID%>").attr("margin-left", "-" + (img.height()) + "px");
$("#overlay").show();
$("#overlayContent").show();
});
I'd use CSS, but I'm not very familiar with using CSS with Javascript, and my clientIDs change since the image name slightly changes on server side thanks to ASP.
The images I'm using to test are 320px X 240px
, for some reason though, the img.width
and img.height
are equaling 24px, which makes no sense. Any suggestions or solutions that resolve this would be greatly appreciated.
Edit Per request, adding full scope of the function in question.