今天來練習切這個畫面
<ol class="list">
<li>
<i class="fa fa-file-text" aria-hidden="true"></i>
收到訂單
</li>
<li class="active">
<i class="fa fa-archive" aria-hidden="true"></i>
撿貨中
</li>
<li>
<i class="fa fa-truck" aria-hidden="true"></i>
運送中
</li>
<li>
<i class="fa fa-check-circle" aria-hidden="true"></i>
送達
</li>
</ol>
@import url("https://fonts.googleapis.com/css?family=Noto+Sans+TC:100,300,400,500,700,900&display=swap");
@import url("https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css");
* {
margin: 0;
padding: 0;
list-style: none;
}
html, body{
height: 100%;
}
body{
display: flex;
align-items: center;
background-color: #546377;
}
.list{
display: flex;
}
.list li{
font-family: "Noto Sans TC", sans-serif;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
width: 100px;
height: 100px;
background-color: #fff;
border-radius: 50%;
}
.list{
width: 100%;
display: flex;
justify-content: center;
}
.list li .fa{
font-size: 25px;
margin-bottom: 5px;
}
.list li + li{
margin-left: 100px;
}
.list li 設定 position: relative; 將連接線固定在這個區塊範圍
用加號選取器設定除了第一個li沒有連接線條以外,其他都要加上
.list li{
font-family: "Noto Sans TC", sans-serif;
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
width: 100px;
height: 100px;
background-color: #fff;
border-radius: 50%;
position: relative;
}
.list li + li::before{
content: '';
position: absolute;
top:0;
bottom:0;
left:-100px;
margin: auto;
width: 100px;
height: 5px;
background-color: #fff;
}
.list li{
font-family: "Noto Sans TC", sans-serif;
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
width: 100px;
height: 100px;
background-color: #fff;
background-image: linear-gradient(9deg, #185a9d, #43cea2);
border-radius: 50%;
position: relative;
font-size: 20px;
color:#fff;
box-shadow: 0px 0px 0px 4px #fff;
}
.list li + li::before{
content: '';
position: absolute;
top:0;
bottom:0;
z-index: -1;
box-shadow: 0px 0px 0px 3px #fff;
margin: auto;
left: -100px;
width: 100px;
height: 5px;
background-color: #43cea2;
}
使用~選取器 設定在class="active"之後的li背景色彩都變成灰色
.list li.active ~ li{
background-image: linear-gradient(9deg, #999 ,#ccc);
}
.list li.active ~ li::before{
background-color: #999;
}
參考資料: 金魚都能懂的這個網頁畫面怎麼切 : 訂單進度條
以上為個人學習筆記整理
若有錯誤,歡迎指正