CSS快遞進度條效果
有網購習慣的朋友可能會注意到一個快遞進度條功能,用來標識物流資訊。
非常直觀的瞭解貨物當前的位置,下面就分享一個類似的效果。
程式碼例項如下:
[HTML] 純文字檢視 複製程式碼執行程式碼<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <style> .steps { width: 760px; height: 95px; position: relative; margin: 0 auto; } .first { position: absolute; width: 230px; height: 95px; position: absolute; top: 0; left: 0; } .first .big-circle { width: 33px; height: 33px; border-radius: 50%; background: #DBD8D8; position: absolute; left: 60px; top: 31px; text-align: center; } .first .min-circle, .second .min-circle, .third .min-circle, .fourth .min-circle { width: 23px; height: 23px; border-radius: 50%; display: inline-block; margin-top: 5px; text-align: center; line-height: 23px; color: #fff; font-size: 14px; font-weight: bold; background: #999; } .round_active { background: #02994C !important; } .first .title { position: absolute; top: 0; left: 50px; line-height: 24px; color: #8A8A8A; } .first .tame { position: absolute; left: 5px; bottom: 0; color: #A19F9D; font-size: 14px; } .first .big-line { width: 186px; height: 10px; background: #DDDEDE; position: absolute; left: 88px; top: 42px; text-align: center; z-index: 999; } .first .min-line, .second .min-line, .third .min-line, .fourth .min-line { width: 190px; height: 4px; margin-top: 3px; background: #999; } .line_active { background: #02994C !important; } .second { width: 210px; position: absolute; top: 0; left: 230px; height: 95px; } .second .big-circle, .third .big-circle, .fourth .big-circle { width: 33px; height: 33px; border-radius: 50%; background: #DBD8D8; position: absolute; left: 43px; top: 31px; text-align: center; } .second .title, .fourth .title, .third .title { position: absolute; top: 0; left: 30px; line-height: 24px; color: #8A8A8A; } .second .tame, .third .tame, .fourth .tame { position: absolute; left: -10px; bottom: 0; color: #A19F9D; font-size: 14px; } .second .big-line, .third .big-line, .fourth .big-line { width: 186px; height: 10px; background: #DDDEDE; position: absolute; left: 71px; top: 42px; text-align: center; z-index: 999; } .third { width: 210px; position: absolute; top: 0; left: 440px; height: 95px; } .fourth { width: 210px; position: absolute; top: 0; left: 648px; height: 95px; } </style> </head> <body> <div class="steps"> <div class="first"> <div class="title"> 拍下商品 </div> <div class="big-circle"> <div class="min-circle round_active"> √ </div> </div> <div class="tame"> 2016年8月30日18:11:25 </div> <div class="big-line"> <div class="min-line line_active"></div> </div> </div> <div class="second"> <div class="title"> 付款到支付寶 </div> <div class="big-circle"> <div class="min-circle round_active"> √ </div> </div> <div class="tame"> 2016年8月30日18:11:25 </div> <div class="big-line"> <div class="min-line line_active"></div> </div> </div> <div class="third"> <div class="title"> 賣家發貨 </div> <div class="big-circle"> <div class="min-circle round_active"> √ </div> </div> <div class="tame"> 2016年8月30日18:11:25 </div> <div class="big-line"> <div class="min-line"></div> </div> </div> <div class="fourth"> <div class="title"> 確認收貨 </div> <div class="big-circle"> <div class="min-circle"> √ </div> </div> <div class="tame"> 2016年8月30日18:11:25 </div> </div> </div> </body> </html>
上面的程式碼實現我們的基本要求,下面介紹一下它的實現過程。
一.程式碼註釋:
[CSS] 純文字檢視 複製程式碼.steps { width: 760px; height: 95px; position: relative; margin: 0 auto; }
快遞進度效果的容器,設定其為相對定位,那麼它的定位子元素位移以它為參考。
通過margin: 0 auto將其設定為水平居中。
[CSS] 純文字檢視 複製程式碼.first { position: absolute; width: 230px; height: 95px; position: absolute; top: 0; left: 0; }
快遞進度的第一個階段。
絕對定位,位移以它的steps父元素為參考。
[CSS] 純文字檢視 複製程式碼.first .big-circle { width: 33px; height: 33px; border-radius: 50%; background: #DBD8D8; position: absolute; left: 60px; top: 31px; text-align: center; }
定義較大灰色的圓形區域。
通過絕對定位將其放置於一個合適區域。
[CSS] 純文字檢視 複製程式碼.first .min-circle, .second .min-circle, .third .min-circle, .fourth .min-circle { width: 23px; height: 23px; border-radius: 50%; display: inline-block; margin-top: 5px; text-align: center; line-height: 23px; color: #fff; font-size: 14px; font-weight: bold; background: #999; }
定義較小深灰色的原型區域。
通過display: inline-block將div元素設定為內聯塊級元素,這樣父元素的text-align: center可以將其設定為居中。
[CSS] 純文字檢視 複製程式碼.round_active { background: #02994C !important; }
元素新增此樣式類之後,能夠優先將背景色設定為#02994C(綠色)。
[CSS] 純文字檢視 複製程式碼.first .title { position: absolute; top: 0; left: 50px; line-height: 24px; color: #8A8A8A; }
通過絕對定位,將標題設定於頂部。
[CSS] 純文字檢視 複製程式碼.first .tame { position: absolute; left: 5px; bottom: 0; color: #A19F9D; font-size: 14px; }
將時間通過絕對定位放置於底部。
[CSS] 純文字檢視 複製程式碼.first .big-line { width: 186px; height: 10px; background: #DDDEDE; position: absolute; left: 88px; top: 42px; text-align: center; z-index: 999; }
設定較粗灰色的橫線。
通過絕對定位將其放置於一個恰當的位置。
[CSS] 純文字檢視 複製程式碼.first .min-line, .second .min-line, .third .min-line, .fourth .min-line { width: 190px; height: 4px; margin-top: 3px; background: #999; }
快遞流程沒有完成時,較細深灰色的橫線。
[CSS] 純文字檢視 複製程式碼.line_active { background: #02994C !important; }
元素新增此樣式類之後,能夠優先將背景色設定為#02994C(綠色)。
二.相關閱讀:
(1).相對定位參閱CSS position:relative 相對定位一章節。
(2).絕對定位參閱CSS position:absolute 絕對定位一章節。
(3).border-radius參閱CSS3 border-radius一章節。
(4).!important參閱CSS !important一章節。
相關文章
- CSS3圓形進度條效果CSSS3
- CSS3進度條效果程式碼CSSS3
- 【新特性速遞】進度條,進度條,進度條
- CSS3實現原型進度條效果CSSS3原型
- 不可思議的純 CSS 滾動進度條效果CSS
- 現代 CSS 高階技巧,完美的波浪進度條效果!CSS
- canvas環形進度條效果Canvas
- jQuery實進度條效果詳解jQuery
- 每日CSS_純CSS製作進度條CSS
- JavaScript 動態進度條效果詳解JavaScript
- iOS實現音訊進度條效果iOS音訊
- 實現環形進度條效果【一】
- jQuery環形旋轉載入進度條效果jQuery
- css3 製作圓環進度條CSSS3
- CSS 如何模擬“真實的”進度條?CSS
- 【新特性速遞】表格中的進度條和評分
- vue中頁面載入進度條效果的實現Vue
- Qt 進度條QT
- svg和css3建立環形漸變進度條SVGCSSS3
- 手把手使用 SVG + CSS 實現漸變進度環效果SVGCSS
- CSS3滾動條效果程式碼CSSS3
- HTML <progress> 進度條HTML
- wkwebView 新增 進度條WebView
- 學習進度條
- 簡單進度條
- Python進度條技巧Python
- canvas 畫進度條Canvas
- Linux 進度條(非100%)列出unzip進度Linux
- Android花樣loading進度條(三)-配文字環形進度條Android
- CSS 線條環形動態運動效果CSS
- 下載速度居然可以這麼快,進度條就靠你拯救了!
- ProgressBar進度條顏色
- icp配準進度條
- N 種僅僅使用 HTML/CSS 實現各類進度條的方式HTMLCSS
- Excel實現完成進度的進度條結果Excel
- Android 自定義圓形旋轉進度條,仿微博頭像載入效果Android
- 推進快遞包裝“綠色革命”
- 數字進度條元件NumberProgressBar元件
- 橡皮筋進度條ElasticProgressBarAST