因此我尝试使用javascript设置背景位置(x,y)坐标。
{{1}}
我不确定将背景位置设置为什么。非常感谢任何帮助!
答案 0 :(得分:0)
只需将您的位置放在String
:
function createPuzzlePiece(piece, x, y) {
piece.classList.add("puzzle-piece");
piece.style.backgroundPosition = x+'px '+y+'px';
}
如果你的x& y是%:
function createPuzzlePiece(piece, x, y) {
piece.classList.add("puzzle-piece");
piece.style.backgroundPosition = x+'% '+y+'%';
}