从右到左增长进度条宽度

时间:2014-06-02 17:57:26

标签: html css twitter-bootstrap-3 width

我有一个进度条,当我增加它的宽度时,它从左到右。就像0%它在我的酒吧左边,100%它在我酒吧的最右边。

我想知道我是否可以通过任何方式使我的进度条能够成长并且#34;从右到左。像" -100%"。

这是我的HTML代码:

<div class="completion-bar1-wraper">
    <div class="completion-bar1"></div>
</div>

和css:

div.completion-bar1-wraper{
    height: 12px;
    border: 1px solid #aaa;
    border-radius: 7px;
    background: #eee;
    box-shadow: 0px 0px 5px 0px #C2C2C2 inset;
    margin-right: 4%;
    margin-left: 3%;
    margin-top: 19%;
}
div.completion-bar1{
    height: 8px;
    margin: 1px;
    border-radius: 7px;
    background: #cf7400;
    width: 70%;
}

我也设置了一个小提琴:Progress Bar

3 个答案:

答案 0 :(得分:1)

您可以通过定位轻松完成。将容器设置为position: relative;,绝对定位进度条,然后指定right: 0;将其放置在容器的右边缘。

div.completion-bar1-wraper {
   /*...*/
    position: relative;
}

div.completion-bar1 {
   /*...*/
    width: 70%;
    position: absolute;
    right: 0;
}

这是fiddle

答案 1 :(得分:1)

有很多方法可以做到这一点,所以回答你的问题,是的。 我已按照以下方式分叉您的代码并稍微调整了css:http://jsfiddle.net/adamfullen/69mJ8/

div.completion-bar1-wraper{
    height: 12px;
    border: 1px solid #aaa;
    border-radius: 7px;
    background: #eee;
    box-shadow: 0px 0px 5px 0px #C2C2C2 inset;
    margin-right: 4%;
    margin-left: 3%;
    margin-top: 19%;
    position: relative;
}
div.completion-bar1{
    position: absolute;
    right:0;
    height: 8px;
    margin: 1px;
    border-radius: 7px;
    background: #cf7400;
    width: 70%;
}

答案 2 :(得分:1)

只需将完成栏1编辑为以下

即可
div.completion-bar1{
    float: right;
    height: 8px;
    margin: 1px;
    border-radius: 7px;
    background: #cf7400;
    width: 70%;
}
相关问题