自定义进度条
效果
index.tsx
import styles from './index.module.scss'
import crystalUrl from './imgs/crystal.png'
import {observer} from 'mobx-react-lite'
import dataStore from 'src/store/dataStore '
const ProgressBar: React.FC = props => {
return(
<div className={styles.progressline}>
<i style={{width: (dataStore.nowAmount / dataStore.TotalAmount) * 100 + '%'}}></i>
<div className={styles.progress}>
{dataStore.nowAmount}/{dataStore.TotalAmount}
<div className={styles.icon_crystal}>
<img src={crystalUrl} />
</div>
</div>
</div>
)
}
export default observer(ProgressBar)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
index.module.scss
.progressline {
position: relative;
left: 10px;
width: 260px;
height: 18px;
line-height: 12px;
background-color: #ffffff;
border-radius: 9px;
border: 1px solid #ffd06c;
overflow: hidden;
text-align: center;
.progress {
position: absolute;
width: 260px;
text-align: center;
.icon_crystal {
margin: 2px 3px 0;
display: inline-block;
width: 14px;
height: 12px;
img {
width: 100%;
}
}
}
i {
position: absolute;
left: 0;
top: 0;
height: 100%;
background-image: linear-gradient(to right, #ffe855, #ffd06c);
border-radius: 9px 0 0;
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34