小熊维尼拼图
代码实现拼图小游戏,鼠标选中拼块,用上下左右键移动拼块。



HTML代码









width: 508px;
height: 631px;
margin: 0 auto;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
border: 1px solid #d5e0e6;
}
container > .row {
display: -webkit-Box;
white-space: nowrap;
}
container > .row > .unit {
width: 169px;
height: 209px;
display: inline-block\9;/兼容IE9/10/
vertical-align: top\9;/兼容IE9/10/
Box-sizing: border-Box;
border: 1px solid rgba(7,157,239,0);
}
container > .row > .unit.move {
border: 1px solid rgba(7,1);
}
tips {
width: 200px;
height: 50px;
background: rgb(152,206,50);
position: absolute;
z-index: 5;
top: -50px;
left: calc(50% - 100px);
opacity: 0;
}
tips > p {
margin: 0;
line-height: 50px;
text-align: center;
color: white;
}
.directions{
width:50%;
margin:0 auto;
text-align: center;
line-height: 30px;
color: white;
background-color: #a7cbf0;
}
jquery代码
} else {
tipsAlert(idName);
}
break;
case 39://右
if (next) {
$(className).insertAfter(next);
} else {
tipsAlert(idName)
}
break;
case 40://下
if (panext) {
var exchangeBottom = $(panext).children()[index];
$(className).insertBefore(exchangeBottom);
if (movenDiv) {
$(exchangeBottom).insertBefore(movenDiv);
} else {
$(exchangeBottom).insertAfter(movepDiv)
}
} else {
tipsAlert(idName);
}
break;
}
});
}
以上这篇jQuery实现拼图小游戏(实例讲解)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持编程之家。