1, the Element center amplification:
1> In addition to changing the width of the element, but also to change the positioning of the element (Left,top), if the picture is enlarged one times, then the displacement is magnified by half the width.
The 2> element must be positioned. Therefore, in the CSS set as a floating layout, you need to use JS to convert the layout, relative to the user's eye position remains unchanged
Note: When using JS to set CSS style, in the same code block, some CSS style settings have higher permissions than other styles.
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Title</title> <style>Body{margin:0;padding:0; }Li{width:100px;Height:100px;Background-color:Red;float: Left;List-style:None;margin:10px 0 0 10px; }#ul1{margin:0;padding:0px;width:330px;margin:100px Auto 0;position:relative; } </style></Head><Scriptsrc= "Startmove.js"></Script><Script>window.onload=function () { varOul=document.getElementById ('UL1'); varALi=Oul.getelementsbytagname ('Li'); varZIndex=1; for(varI=0; I<Ali.length;i++) {Ali[i].style.left=Ali[i].offsetleft+'px'; Ali[i].style.top=Ali[i].offsettop+'px'; Ali[i].pos={left:ali[i].offsetleft,top:ali[i].offsettop}; } for (varI=0; I<Ali.length;i++) {ali[i].style.position='Absolute'; Ali[i].style.margin='0px'; Ali[i].onmouseover=function () { This. Style.backgroundcolor='Blue'; This. Style.zindex=ZIndex++; Startmove ( This, {width: $, Height: $, left: This. Pos.left- -, Top: This. Pos.top- - }); } ali[i].onmouseout=function () { This. Style.backgroundcolor='Red'; Startmove ( This, {width: -, Height: -, left: This. Pos.left, Top: This. Pos.top}); } } }</Script><Body> <ulID= "UL1"> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> <Li></Li> </ul></Body></HTML>
Using JS to realize image expansion and contraction