用于将活动指示符放置到单元格的JavaScript代码
我使用以下代码(没有我自己的代码)将图像加载到css元素(称为单元格)并显示活动指示器。
var cell = document.createElement('li'); cell.textContent = this.labelForIndex(index); var indicator = new NKActivityIndicator(); indicator.init(10,100,20,"white"); indicator.show(); indicator.spin(); $(cell).css("background-image", "url("+iconImage+")");
现在我想把指标放在cell的中间。这行代码indicator.init(10,100,20,"white");
定义指标的位置宽度和颜色。 我想将它放在cell的中间。任何回应?
您可以使用jQuery的.position()或.offset()来检索单元格的位置,并使用.height()和.width(),您可以将组件放在单元格的中间。
像我们在评论中的所有谈话一样:
你需要的只是$(cell).width()和$(cell).height()
而不是.position()或.offset(),这次不是……