BootStrap初學者對彈出框和進度條的使用感覺_javascript技巧

來源:互聯網
上載者:User

Bootstrap,來自 Twitter,是目前最受歡迎的前端架構。Bootstrap 是基於 HTML、CSS、JAVASCRIPT 的,它簡潔靈活,使得 Web 開發更加快捷。

bootstrap 架構提供的進度條,如菜鳥教程裡面的這些代碼

<div class="progress"><div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 40%;"><span class="sr-only">40% 完成</span></div></div>

讓我這種真正的菜鳥一開始不知道該如何....讓其變為真正的進度條。不過進過百度幾下別人的之後,只要這個是要添加jquery代碼配合之下才能實現滴。我度呀度,終於實現如下,略帶高興。

<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" style="width:300px"> <div class="modal-dialog"> <div class="modal-content" > <span style="text-align:center;color:red">檔案正在上傳請勿重新整理頁面!</span><br /> <div class="progress progress-striped active"> <div class="bar"> </div> </div> </div> </div> </div> 

上面這段是,用彈出框裡麵包含進度條。不然怎麼實現一個開始讓其隱藏的呢?在用bootstrap 做進度條,或者固定的彈出框時,加上data-backdrop="static" 這句比較好,因為沒有這個修飾,你只要點擊下滑鼠,彈出框就消失不見了。

<scripts> var p = 101; var stop = 1; function run() { p += 4; $("div[class=bar]").css("width", p + "%"); var timer = setTimeout("run()", 500); if (p >100&&stop<1) { p = 0; } } $('#BtnSubmit').click(function () { $('#myModal1').modal('show'); p = 0; stop = 0; run(); $('#UpLoad').submit(); }); </scripts> 

其實,bootstrap的進度條是通過css樣式進行展現的,所以只要不斷滴修改,style width的值,就可以顯示出來。當然我這個迴圈,重現重新整理頁面才能重新隱藏掉進度條。若是,用post提交,然後根據傳回值進行判斷,然後用$('#myModal1').modal('hide');將其隱藏,stop的值相應滴就改為1,不然會在一直跑滴。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.