我有一个img元素,我正在尝试使用以下代码设置css属性:
var image = smallImageData.clone().css({
'position':'absolute',
'left':(galleryBB['w'] - w)/2 + 'px',
'top':((galleryBB['h']-6) - h)/2 + 'px',
'width':w + 'px',
'height':h + 'px'
});
其中smallImageData是< img>元件。但是,有时候,并不总是不会设置所有的css属性。具体来说,位置正确设置为“绝对”,但根本没有设置左,顶部,宽度和高度。我在这个语句之前和之后放了一个日志语句,并验证这实际上是罪魁祸首(即jQuery永远不会设置属性,它们不会在其他地方被取消)。
有谁知道为什么会发生这种情况?