我在jsFiddle上设置了一个示例,jQuery当前将宽度设置为固定像素宽度.因此,当浏览器宽度减小时,条形图会从屏幕向右移动.我的问题是如何让jQuery将宽度设置为百分比?
<div class="bars">
<div class="meter">
<span style="width: 88%"></span>
</div>
<div class="meter">
<span style="width: 62%"></span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
$(".meter > span").each(function() {
$(this)
.data("origWidth", $(this).width())
.width(0)
.animate({
width: $(this).data("origWidth")
}, 3600);
});
Run Code Online (Sandbox Code Playgroud)