CSS/进度条
来自康健生活
< CSS
引言
圆环
conic-gradient
支持
垫片
示例
<div className={cls(styles.section_content, 'clearfix')}>
<div className={cls(styles.section_content_icon_box, 'section_content_icon_box_style')}>
<div className={styles.section_content_icon}
onClick={()=>{setIsShowMenu(true)}}>
</div>
</div>
</div>
.section_content_icon_box{
position: relative;
float: right;
width: 50px;
height: 50px;
text-align: center;
line-height: 50px;
background: conic-gradient(
#4D4D57 45deg, transparent 45deg 135deg, transparent 180deg);
border-radius: 50%;
margin-top: 82px;
z-index: -2;
&::after{
content: '';
position: absolute;
top: 2px;
left: 2px;
width: 46px;
height: 46px;
background: white;
border-radius: 50%;
z-index: -1;
}
}
.section_content_icon{
display: inline-block;
width: 40px;
height: 40px;
background: url("../../../assets/home/菜单@3x.png") no-repeat;
background-size: 100% 100%;
margin-top: 5px;
}
useEffect(()=>{
//监听火狐鼠标滚动事件
document.addEventListener("DOMMouseScroll", handleScroll, false);
//监听谷歌苹果浏览器滚动事件
document.addEventListener("mousewheel", handleScroll, false);
// useEffect中要移除刚刚监听的事件,否则如果有路由跳转到下个页面会继续监听
return () => {
document.removeEventListener("DOMMouseScroll", handleScroll, false);
document.removeEventListener("mousewheel", handleScroll, false);
}
});
useEffect(()=>{
(document.getElementsByClassName('section_content_icon_box_style') as HTMLCollectionOf<HTMLElement>)[0].style.background = `conic-gradient(#4D4D57 ${45*(pageIndex-1)}deg, transparent ${45*(pageIndex-1)}deg ${180 - 45*(pageIndex-1)}deg, transparent 180deg)`;
}, [pageIndex]);
const handleScroll = (event: any)=>{
//判断鼠标滚轮的上下滑动
let deta = event.deltaY || 0;
if(deta > 0){
pageIndex<5 && setPageIndex(pageIndex+1);
}else{
pageIndex>1 && setPageIndex(pageIndex-1);
}
}

示例一
<div className={styles.bar_circle}>
<div className={styles.circle}></div>
</div>
.bar_circle{
position: relative;
height: 200px;
width: 200px;
border-radius: 100%;
background: linear-gradient(#697ad9,#b483de);
.circle {
position: relative;
height: 200px;
width: 200px;
background: #fff;
border: 12px solid transparent;
border-radius: 50%;
background-clip: padding-box;
}
}

示例二
<div className={styles.bar}>
<div className={cls(styles.left, styles.wrapper)}>
<div className={cls(styles.circle, styles.leftcircle)}></div>
</div>
<div className={cls(styles.right, styles.wrapper)}>
<div className={cls(styles.circle, styles.rightcircle)}></div>
</div>
</div>
.progress_container{
position: fixed;
width: 100%;
z-index: 10000;
}
.bar{
position: relative;
width: 199px;
height : 200px;
.wrapper{
width: 100px;
height: 200px;
position: absolute;
top:0;
overflow: hidden;
}
.right{
right:0;
}
.left{
left:0;
}
.circle{
width: 160px;
height: 160px;
border:20px solid transparent;
border-radius: 50%;
position: absolute;
top:0;
transform : rotate(-135deg);
box-sizing: content-box;
}
.rightcircle{
border-top:20px solid green;
border-right:20px solid green;
right:0;
animation: circle_right 5s linear infinite;
}
.leftcircle{
border-bottom:20px solid green;
border-left:20px solid green;
left:0;
animation: circle_left 5s linear infinite;
}
}
@keyframes circle_right{
0%{
transform: rotate(-135deg);
}
50%,100%{
transform: rotate(45deg);
}
}
@keyframes circle_left{
0%,50%{
transform: rotate(-135deg);
}
100%{
transform: rotate(45deg);
}
}
No categories