我有一个 twitter 引导进度条,其定义如下:
<div style='position: relative' class='progress progress-info'>
<div class='bar' id='signalRtensionNegPercentage-#:ViewUnitContract.ConveyanceId #' style='display: block; float: right; width: 15%'>
</div>
<span class='gridSpan' id='signalRtensionNeg-#:ViewUnitContract.ConveyanceId #'>#: TensionNegative#</span>
</div>
该#: ... #
部分是由 SignalR 和 Kendo-UI 处理的动态 id。在我的 SignalR 脚本中,我像这样设置百分比宽度:
messageHub.client.notifyTension = function (tensionMessage, conveyanceId) {
var maxTensionRange = $('#signalRmaxTensionRange-' + conveyanceId).text();
var minTensionRange = -maxTensionRange;
var tensionPos = $('#signalRtensionPos-' + conveyanceId).text();
var tensionNeg = $('#signalRtensionNeg-' + conveyanceId).text();
var percentageValPos;
var percentageValNeg;
if (maxTensionRange != 0 && minTensionRange != 0) {
if (tensionMessage < 0) {
percentageValNeg = Math.abs((tensionNeg / (maxTensionRange - minTensionRange)) * 100);
$('#signalRtensionNegPercentage-' + conveyanceId).width(percentageValNeg);
$('#signalRtensionNeg-' + conveyanceId).text(tensionMessage);
} else {
percentageValPos = Math.abs((tensionPos / (maxTensionRange - minTensionRange)) * 100);
$('#signalRtensionPosPercentage-' + conveyanceId).width(percentageValPos);
$('#signalRtensionPos-' + conveyanceId).text(tensionMessage);
}
}
};
我的问题是整个栏似乎在扩大,而不是蓝色填充物(进度条)。我猜这是因为设置了$('#signalRtensionNegPercentage-' + conveyanceId).width(percentageValNeg);
部分。任何人都知道我可以如何设置 style: width 属性,以便定义百分比宽度?