CSS自定义进度条
Posted 嘻嘻的妙妙屋
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CSS自定义进度条相关的知识,希望对你有一定的参考价值。
自定义进度条
效果
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)
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;
![](https://image.cha138.com/20220624/4dae975ffafc4952abf3a99fbfab72e7.jpg)
![](https://image.cha138.com/20220624/e2626a5e166c4632b7f065cd94cdd0b5.jpg)
以上是关于CSS自定义进度条的主要内容,如果未能解决你的问题,请参考以下文章