Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fill progress bar in x seconds

I have this code...

HTML

<div class="progress-bar">
    <span class="progress-bar-fill" style="width: 30%"></span>
</div>

CSS

.progress-bar {
    width: calc(100% - 6px);
    height: 5px;
    background: #e0e0e0;
    padding: 3px;
    border-radius: 3px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, .2);
}

.progress-bar-fill {
    display: block;
    height: 5px;
    background: #659cef;
    border-radius: 3px;
    transition: width 250ms ease-in-out;
}

It's supposed to show the progress of slider and how long the current image will last till the next one apperas....

If the image changes every 5 seconds, then I want the bar to fill out 100% in 5 seconds... I'm total noob in javascript and jQuery...

like image 708
Reel Avatar asked Oct 13 '15 07:10

Reel


People also ask

How do you code progress bar?

Use the <progress> tag to create a progress bar in HTML. The HTML <progress> tag specifies a completion progress of a task. It is displayed as a progress bar. The value of progress bar can be manipulated by JavaScript.

How do I create a progress bar in Visual Studio?

Create a custom ProgressBar controlStart Microsoft Visual Studio. On the File menu, point to New, and then click Project. In the New Project dialog box, click Visual C# under Project Types, and then click Windows Forms Control Library under Templates. In the Name box, type SmoothProgressBar, and then click OK.


1 Answers

You can use it.

Update :- make transition 5 second.

transition: width 5s ease-in-out;

$('.progress-bar-fill').delay(1000).queue(function () {
        $(this).css('width', '100%')
    });
.progress-bar {
    width: calc(100% - 6px);
    height: 5px;
    background: #e0e0e0;
    padding: 3px;
    border-radius: 3px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, .2);
}

.progress-bar-fill {
    display: block;
    height: 5px;
    background: #659cef;
    border-radius: 3px;
    /*transition: width 250ms ease-in-out;*/
    transition: width 5s ease-in-out;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="progress-bar">
    <span class="progress-bar-fill" style="width: 30%"></span>
</div>

I hope it will helps you.

like image 95
Mukul Kant Avatar answered Nov 15 '22 15:11

Mukul Kant