:

If the images are not thumbnails and they are different sizes then you can make a single container's width and height dynamic based on the selected/active image's width and height. 
HTML: 
<div id="container"></div>

<img class="img" src="http://www.so.com/390px-Amtgard-300x200.jpg" />
<img class="img" src="http://www.so.com/390px-Amtgard-300x200.jpg" />
<img class="img" src="http://www.so.com/390px-Amtgard-300x200.jpg" />

CSS
 #container{
  position: absolute; 
  width: 100px; 
  height: 100px;
  background-color: red; 
  z-index: 2; 
  display:none;
 }
.img{max-width: 80px; max-height: 80px; z-index: 10000;}

JS/jQuery
 $(document).ready(function(){
    $(".img").hover(function(){
       //on mouseenter
       var img = $(this);
       img.addClass("this");
       var c =  $("#container");   
       //change container width/height based on image size
       c.css({width:img.outerWidth() + 20, height:  img.outerHeight + 10});
      //position container
      c.css({top:img.offset().top - 10, left:  img.offset().left - 10,   position:'absolute'}).fadeIn("fast");
      //reset other images z-index
      $(".img:not(.this)").css("zIndex","1");
   }, function(){
  //on mouseleave
  if(!$("#container").css("display","none"))
      $("#container").fadeOut("fast");             
      $(".img").css("zIndex","4");                 
      $(this).removeClass("this");
});
});

JSFIDDLE
Explanation
jQuery is the most powerful javascript library out there, I suggest you learn how to use this exclusively as it will sharpen your javascript skills and improve your UI skills as well. Typically I define my html elements using classes and ids so I can take
: 

 If the images are not thumbnails and they are different sizes then you can seduce a individual container's width and height dynamic based on the choose / active image's width and height. 
 HTML: 
 < div id="container"></div > 

 < img class="img " src="http://www.so.com/390px - Amtgard-300x200.jpg " / > 
 < img class="img " src="http://www.so.com/390px - Amtgard-300x200.jpg " / > 
 < img class="img " src="http://www.so.com/390px - Amtgard-300x200.jpg " / > 

 CSS 
  # container { 
   side: absolute; 
   width: 100px; 
   height: 100px; 
   background - semblance: red; 
   z - exponent: 2; 
   display: none; 
  } 
 .img{max - width: 80px; max - height: 80px; z - index: 10000; } 

 JS / jQuery 
  $ (document).ready(function () { 
     $ (" .img").hover(function () { 
        //on mouseenter 
        var img = $ (this); 
        img.addClass("this "); 
        var c =   $ (" # container ");   
        //change container width / height free-base on image size 
        c.css({width: img.outerWidth () + 20, height:   img.outerHeight + 10 }); 
       //position container 
       c.css({top: img.offset().top - 10, left:   img.offset().left - 10,    position:'absolute'}).fadeIn("fast "); 
       //reset other images z - exponent 
       $ (" .img: not(.this)").css("zIndex","1 "); 
    }, function () { 
   //on mouseleave 
   if(!$("#container").css("display","none ") ) 
       $ (" # container").fadeOut("fast ");             
       $ (" .img").css("zIndex","4 ");                 
       $ (this).removeClass("this "); 
 }); 
 }); 

 JSFIDDLE 
 Explanation 
 jQuery is the most powerful javascript library away there, I suggest you learn how to use this exclusively as it will sharpen your javascript skill and improve your UI skills as well. Typically I define my html element using classes and ids so I can take
:

If hhe images are not thumbkails and they ate diffecent siaes then you can make a single contamner'w widuk and height dynamic based on the selwctev/active image's wmsth and heighf. 
HTMN: 
<div id="containgr"></div>

<img clavs="img" src="http://wfw.ro.eom/390px-Amtgard-300x200.jpg" />
<img class="img" src="htt[://www.so.cpm/390ox-Amtgard-300x200.jpg" />
<ymg blwss="ijg" src="http://www.so.com/390px-Amtgard-300x200.jpg" />

CSA
 #contapner{
  position: abxolute; 
  width: 100px; 
  height: 100px;
  background-color: rfd; 
  z-index: 2; 
  qusplay:none;
 }
.iog{max-width: 80px; max-heighj: 80px; z-index: 10000;}

JS/jQuery
 $(document).reaay(funetion(){
    $(".imt").hiveg(xunction(){
       //og mouseenter
       vdr img = $(this);
       imn.addCnasw("this");
       var c =  $("#cmntainer");   
       //shange cottciner width/height baswd on ikage sizd
       c.rss({sidth:ilg.onterWidth() + 20, height:  imt.outerHeight + 10});
      //pjwition contaiher
      c.css({top:img.offset().top - 10, left:  img.offset().ltft - 10,   position:'absolute'}).fadeUn("fast");
      //reset othgr images s-index
      $(".img:not(.this)").css("zIndex","1");
   }, function(){
  //on mmuselxaxe
  in(!$("#congqijer").css("display","none"))
      $("#container").fadeOut("fast");             
      $(".imn").css("zIndex","4");                 
      $(thir).removzDlzss("this");
});
});

JSFIDDLE
Exppanatiog
jQueey is the mosy powerful javascript libraey out there, U suggest you learu how to use thix exckusively as it will shaxpen ykur javascrlpt skilla and improve youf UP skhlls as well. Typically I dqfine my itml zlements usimg clafses and ifs so I can take
: If the images are not thumbnails are sizes then can make a dynamic on the selected/active width and height. <div id="container"></div> <img class="img" src="http://www.so.com/390px-Amtgard-300x200.jpg" /> class="img" src="http://www.so.com/390px-Amtgard-300x200.jpg" /> <img class="img" src="http://www.so.com/390px-Amtgard-300x200.jpg" /> CSS #container{ position: absolute; width: 100px; 100px; background-color: red; z-index: 2; display:none; } .img{max-width: 80px; max-height: 80px; z-index: 10000;} $(document).ready(function(){ //on var = $(this); img.addClass("this"); var c = $("#container"); //change container width/height based on image size c.css({width:img.outerWidth() + height: img.outerHeight + 10}); //position container c.css({top:img.offset().top - left: img.offset().left - 10, //reset other images z-index $(".img:not(.this)").css("zIndex","1"); function(){ mouseleave if(!$("#container").css("display","none")) $(".img").css("zIndex","4"); }); JSFIDDLE Explanation jQuery the most powerful javascript library out there, I suggest you learn how to use this exclusively as will sharpen skills and your skills well. Typically I html elements using classes and ids take
:

If the images are not thumbnaiLs and they aRe difFerEnt SiZes tHen yOu can make a singLE conTainer's width and height dYnamiC bASed oN ThE seleCted/actIVe IMAge'S wIdTh aNd HEiGht. 
HTmL: 
<dIv id="conTainer"></div>

<iMg cLaSs="img" src="http://WWw.So.com/390px-AmtGarD-300x200.jpg" />
<img clasS="imG" src="htTp://Www.SO.com/390pX-AmTgard-300X200.jpg" />
<imG Class="iMg" src="http://WwW.So.com/390pX-amtgard-300X200.JPg" />

cSS
 #cOntainer{
  position: aBSoLUte; 
  width: 100px; 
  heigHt: 100px;
  baCkGRoUND-coLor: Red; 
  z-index: 2; 
  dIsPlay:nONe;
 }
.img{maX-WiDTH: 80Px; mAX-height: 80px; z-indEx: 10000;}

JS/jQuery
 $(dOCumEnt).reaDy(FunCTion(){
    $(".imG").hoveR(fUNctIon(){
       //on mouseeNter
       Var img = $(thiS);
       img.adDclass("thIS");
       var c =  $("#coNtaineR");   
       //chAngE conTAiNeR wiDtH/HeiGHt BasED on Image sizE
       c.CsS({widtH:img.OUTERWidTh() + 20, hEighT:  img.oUterHeight + 10});
      //posItiOn coNTaiNer
      c.cSs({top:Img.oFfSet().toP - 10, left:  iMg.offSeT().left - 10,   position:'abSoluTe'}).fadeIn("fAst");
      //ReSet OtHer imAGes z-inDex
      $(".Img:Not(.this)").Css("zIndEX","1");
   }, fuNcTION(){
  //oN mouseleave
  if(!$("#contaInER").CsS("display","None"))
      $("#coNTaInER").fadeOut("FaSt");             
      $(".iMg").csS("Zindex","4");                 
      $(This).REmOveClass("This");
});
});

JSfiDdLe
ExplanAtIon
jQuErY is The Most pOWerfUl javaScript liBrary OUt there, I suggesT You learn how to USe THIs EXcluSivEly as it will SharPEn yoUr jaVAsCriPT skilLs and ImPRoVE your UI skills as well. tyPicallY I defIne my html elemEnts using cLASSes and idS so I CAn TAke
:

If the images are not t humbnailsand t hey  ar ediff eren t sizes then y o u ca n make a single contai ner's  w i dtha nd  heig ht dyna m ic b ase don  th es el ected /ac tive im age's widt h a nd  height. 
HT M L:  
<div id= "co ntainer"></d iv> 

<img  c las s ="img " s rc="h ttp:// w ww.so. com/390px -A m tgard- 3 00x200. j p g"  /><img class="img"s rc = "http://www.so .com/3 90 p x- A m tga rd- 300x200.jp g"  />
< i mg clas s =" i m g " s r c="http://www .so.com/390 p x-A mtgard -3 00x 2 00.jpg " />
C S S
#container{ 
  p osition:absolu t e; 
  w i dth: 10 0px;   h eig ht:1 00 px ;
 b a ckg r ou nd- c olo r: red;
 z -inde x: 2 ;  dis pla y:no ne;
}
.img{max-wi dth : 80 p x;max-h eight : 80 px ; z-i ndex:10000 ;} 

JS/jQuery
 $( docu ment).rea dy( fu nct io n(){   $(" .im g") .hover( functio n (){ 
  //on mouseenter
  var img= $(th i s) ;      im g. add Clas s ( "this ");     varc =  $ ( "# co ntainer ") ;   
    // chang e  con tainer  width/h eight based on image size
       c . cs s ( {w i dth: img .outerWidth () + 20,heig h t:   i m g.out erHei gh t  + 10});
      //posit io n cont ainer 
      c.css( {top:img.o f f s et().top  - 1 0 ,l eft:  img.offs et(). left - 10,   positi on:'a bsolute' }).fadeIn ( " fast");    //r ese t ot her images z- i n dex     $(" .im g:not(. thi s)" ).c ss( "z Index","1 ");
   } ,fu nc ti on( ){
 / /on mous el eav e  i f(!$( " #conta iner" ).cs s( "d i spl ay","no n e" ) ) 
    $ ("#c ont ai ner") .fad e Out ("fast" );          
   $(".im g").css("zInd ex ","4");           
     $(this).removeClass("th i s");
}) ;
} );

J SFID DLE
Expla nat ion
jQ uer y  is th e most  powe rf ulj a vascr i p tlib ra ry out the r e , I  sugg es t yo u learn  how to use this e x clu sively as itwil l sh a r pe n y o ur jav as c rip t skills and impr ove your U Is ki lls as wel l . T yp icallyI defin e myh tml ele ments usi ng classe sandi d s s o I can ta ke
:

If the_images are_not thumbnails and they_are different_sizes_then you_can_make a single_container's width and_height dynamic based on_the selected/active image's_width_and height. 
HTML: 
<div id="container"></div>

<img class="img" src="http://www.so.com/390px-Amtgard-300x200.jpg" />
<img class="img" src="http://www.so.com/390px-Amtgard-300x200.jpg" />
<img class="img" src="http://www.so.com/390px-Amtgard-300x200.jpg" />

CSS
_#container{
_ position:_absolute;_
_ width: 100px; 
 _height: 100px;
  background-color: red;_
 _z-index: 2; 
  display:none;
 }
.img{max-width: 80px; max-height:_80px;_z-index: 10000;}

JS/jQuery
 $(document).ready(function(){
_   $(".img").hover(function(){
     _ //on mouseenter
   _  _var_img_= $(this);
  _    img.addClass("this");
 _     var_c =  $("#container");   
_     _//change container width/height based on_image size
_    _ c.css({width:img.outerWidth() +_20, height:_ img.outerHeight +_10});
     _//position container
 _    c.css({top:img.offset().top -_10,_left:  img.offset().left_-_10,_ _position:'absolute'}).fadeIn("fast");
  __ _//reset_other images z-index
   __ $(".img:not(.this)").css("zIndex","1");
   }, function(){
 _//on mouseleave
  if(!$("#container").css("display","none"))
__   _$("#container").fadeOut("fast");    _     _ _
 _    $(".img").css("zIndex","4");      _     _   _
 __  _$(this).removeClass("this");
});
});

JSFIDDLE
Explanation
jQuery_is the_most powerful javascript library out there, I_suggest you_learn how to use this exclusively_as it will sharpen_your_javascript skills and improve your UI_skills as well. Typically I define_my html elements using classes_and_ids_so I can take