1 <!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">2 <HTMLxmlns= "http://www.w3.org/1999/xhtml">3 <Head>4 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" />5 <title>Untitled Document</title>6 <Linkrel= "stylesheet"type= "Text/css"href= "Css/common.css" />7 <styletype= "Text/css">8 #box{width:600px;Height:630px;background:#CCC;margin:0 Auto;padding:5px;Padding-left:35px;}9 #box Div{float: Left;width:60px;Height:60px;background:URL (img/pic.jpg) no-repeat;Opacity:0;margin:1px;}Ten </style> One </Head> A - <Body> - <DivID= "box"class= "Clearfix"> the </Div> - <Script> - varOBox=document.getElementById ("Box"); - varOdiv=Obox.getelementsbytagname ("Div"); + varStr= ""; - for(varI=0; I< -; I++) + Str+= "<div></div>"; A obox.innerhtml=str; at for(varI=0; I< -; I++) - { - Odiv[i].style.top=parseint (i/9) *61+ "px"; - Odiv[i].style.left=I%9* A+"px"; - varCo= -(parseint (i/9) *61); - varro= -(i%9* A); in odiv[i].style.backgroundposition=ro+"px"+" "+Co+"px"; - Odiv[i].onmouseover= function(){ to This. Style.opacity= "1"; + }; - } the * </Script> $ </Body>Panax Notoginseng </HTML>
Show background picture based on mouse move position