body { background-color:rgb(247,238,217); } /*div#img img { width:500px; height:500px; } */ div#GameButton { width:120px; margin:0 auto; } .img0 { background-repeat:no-repeat; background-position:0px 0px; } .img1 { background-repeat:no-repeat; background-position:-168px 0px; } .img2 { background-repeat:no-repeat; background-position:-336px 0px; } .img3 { background-repeat:no-repeat; background-position:0px -168px; } .img4 { background-repeat:no-repeat; background-position:-168px -168px; } .img5 { background-repeat:no-repeat; background-position:-336px -168px; } .img6 { background-repeat:no-repeat; background-position:0px -336px; } .img7 { background-repeat:no-repeat; background-position:-168px -336px; } .img8 { background-repeat:no-repeat; background-position:-336px -336px; } td { width:168px; height:168px; background-size:504px 504px; }
在js文件头部,可设置包括成功提示函数等自定义内容。
代码中有详细注释,方便大家修改。
你好,我想请问一下,这部分代码如何改变使原图片被切分成2*2或3*3呢?
for (i = 0, td = document.getelementsbytagname('td'); i < td.length; i++) { td[i].setattribute('class', 'img' + i); td[i].setattribute('id', i); td[i].style.height = "168px"; td[i].style.width = "168px"; td[i].style.position = "absolute"; td[i].style.left = i % _row * (168 + table_cellspacing) + (parseint(i % _row / _row) + 1) * margin + "px"; td[i].style.top = parseint(i / _col) * (168 + table_cellspacing) + "px";
小白。。没看太懂