如何使用jQuery / Javascript更改同一元素上的多个背景图像位置

时间:2015-11-06 03:50:29

标签: javascript jquery

$("#d_header-right-lower li." + navEl).css("background-image","url('/header/bg-nav.png'), url('/header/bg-nav-separate.gif')");
$("#d_header-right-lower li." + navEl).css("background-position","0 13px");
$("#d_header-right-lower li." + navEl).css("background-position","bottom center");
$("#d_header-right-lower li." + navEl).css("background-repeat","no-repeat, no-repeat");

第二个bottom center我不需要background-image (bg-nav-separate.gif);有没有办法只将其应用于第一个background-image (bg-nav.png)

$("#d_header-right-lower li." + navEl).css("background-position (for first image only)","bottom center");

1 个答案:

答案 0 :(得分:1)

尝试将for (var i =bottomleft.x, px =0 ; i < topRight.x; i = i + voxelSize, px = px + pixWidthVoxel){ for (var j = bottomleft.y, py =0 ; j < topRight.y ; j = j + voxelSize, py = py + pixHeightVoxel){ var pixelValues = new Uint8Array(voxelWidthPixel * voxelHeightPixel * 4); gl.readPixels( startPixelX, startPixelY, endPixelX, endPixelY, gl.RGBA, gl.UNSIGNED_BYTE, pixelValues); } } 属性的第二个参数设置为background-position,同时调用0 13px,参数用逗号.css()分隔;删除对,的第二次通话。见Using CSS multiple backgrounds

.css("background-position")

jsfiddle https://jsfiddle.net/rgwnye91/1/