小编Hug*_* DB的帖子

获取jQuery将宽度设置为百分比而不是像素

在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)

html javascript css jquery

6
推荐指数
1
解决办法
4587
查看次数

标签 统计

css ×1

html ×1

javascript ×1

jquery ×1