本文將為大家詳細(xì)介紹“javascript+css實(shí)現(xiàn)進(jìn)度條效果的示例”,內(nèi)容步驟清晰詳細(xì),細(xì)節(jié)處理妥當(dāng),而小編每天都會(huì)更新不同的知識(shí)點(diǎn),希望這篇“javascript+css實(shí)現(xiàn)進(jìn)度條效果的示例”能夠給你意想不到的收獲,請(qǐng)大家跟著小編的思路慢慢深入,具體內(nèi)容如下,一起去收獲新知識(shí)吧。
Java是一門(mén)面向?qū)ο缶幊陶Z(yǔ)言,可以編寫(xiě)桌面應(yīng)用程序、Web應(yīng)用程序、分布式系統(tǒng)和嵌入式系統(tǒng)應(yīng)用程序。
具體內(nèi)容如下
主要是以樣式實(shí)現(xiàn)進(jìn)度條的效果,JavaScript控制顯示的百分比
html模板
<div class="progress_area"> <span id="progress" class="progress_bac"></span> </div> <input type="button" class="progress-inp" value="100%" οnclick="progress(100);"/> <input type="button" class="progress-inp" value="86%" οnclick="progress(86);" /> <input type="button" class="progress-inp" value="20%" οnclick="progress(20);"/>
css:
.progress_area{ width: 255px; height: 13px; border: 1px solid #ccc; border-radius: 15px; margin-bottom: 30px; } .progress-inp{ width: 60px; height: 28px; border: 1px solid #ccc; background: #62c7ef; border-radius: 8px; color: white; cursor: pointer; outline:none; } .progress_bac{ display: block; height: 100%; width: 50%; background: #83a4f1; border-radius: 10px; }
實(shí)現(xiàn)的效果:
感覺(jué)這個(gè)進(jìn)度條顯示的特別生硬;之后通過(guò)box-shadow對(duì)它加了個(gè)陰影效果:
box-shadow有6個(gè)參數(shù):
box-shadow:inset x-offset y-offset blur-radius spread-radius color
分別為:投影方式 X軸偏移量 Y軸偏移量 陰影模糊半徑 陰影擴(kuò)展半徑 陰影顏色
css:
.progress_bac{ display: block; height: 100%; width: 50%; background: #83a4f1; border-radius: 10px; -moz-box-shadow:0px 0px 7px 0px #4486ca; -webkit-box-shadow:0px 0px 7px 0px #4486ca; box-shadow:0px 0px 7px 0px #4486ca; }
效果:
陰影的顏色可以自定義,通過(guò)box-shadow可以實(shí)現(xiàn)高亮的效果,多多嘗試;
在點(diǎn)擊下方按鈕的時(shí)候,進(jìn)度條會(huì)顯示對(duì)應(yīng)的值,到指定的位置,但是通過(guò)之上的代碼來(lái)看,當(dāng)點(diǎn)擊按鈕的時(shí)候進(jìn)度條是一下子就到了指定的位置,沒(méi)有過(guò)度的效果;
通過(guò)javascript和css兩種方式來(lái)實(shí)現(xiàn):
css:
css來(lái)實(shí)現(xiàn)很簡(jiǎn)單,css中有個(gè)參數(shù)叫transition動(dòng)畫(huà)效果,通過(guò)改變改參數(shù)的寬度的動(dòng)畫(huà)效果,很簡(jiǎn)單的就實(shí)現(xiàn)出來(lái)
.progress_bac{ display: block; height: 100%; width: 50%; background: #83a4f1; border-radius: 10px; -moz-box-shadow:0px 0px 7px 0px #4486ca; -webkit-box-shadow:0px 0px 7px 0px #4486ca; box-shadow:0px 0px 7px 0px #4486ca; -moz-transition: width 0.5s; -webkit-transition: width 0.5s; transition: width 0.5s; }
javascript:
js實(shí)現(xiàn)的方式就有多種了可以寫(xiě)個(gè)循環(huán)可以寫(xiě)個(gè)定時(shí)器:以下代碼就是用定時(shí)器寫(xiě)的;
function progress(value){ if ( value ){ var num = ""; var loader_progress = setInterval(function(){ num++; document.getElementById("progress").style.width = num+"%"; if ( num == value ){ clearInterval(loader_progress); } },10); } };
如果你能讀到這里,小編希望你對(duì)“javascript+css實(shí)現(xiàn)進(jìn)度條效果的示例”這一關(guān)鍵問(wèn)題有了從實(shí)踐層面最深刻的體會(huì),具體使用情況還需要大家自己動(dòng)手實(shí)踐使用過(guò)才能領(lǐng)會(huì),如果想閱讀更多相關(guān)內(nèi)容的文章,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
標(biāo)題名稱(chēng):javascript+css實(shí)現(xiàn)進(jìn)度條效果的示例-創(chuàng)新互聯(lián)
網(wǎng)站網(wǎng)址:http://www.chinadenli.net/article20/dcijco.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、品牌網(wǎng)站設(shè)計(jì)、手機(jī)網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)、定制網(wǎng)站、電子商務(wù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容