查看“︁CSS/进度条”︁的源代码
来自康健生活
←
CSS/进度条
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
== 引言 == == 圆环 == === conic-gradient === ==== 支持 ==== * https://caniuse.com/?search=conic-gradient 垫片 * https://projects.verou.me/conic-gradient/conic-gradient.js ==== 示例 ==== {{codetab|tabs=<tabs><tab name="html"><syntaxhighlight lang="html5"> <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></syntaxhighlight></tab><tab name="css"><syntaxhighlight lang="css">.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; } </syntaxhighlight></tab><tab name="js"><syntaxhighlight lang="javascript">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); } } </syntaxhighlight></tab></tabs>|}} [[文件:圆环进度条.gif|400px|无框|无|圆环进度条]] === 示例一 === {{codetab|tabs=<tabs><tab name="html"><syntaxhighlight lang="html5"> <div className={styles.bar_circle}> <div className={styles.circle}></div> </div></syntaxhighlight></tab><tab name="css"><syntaxhighlight lang="css">.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; } } </syntaxhighlight></tab></tabs>}} [[文件:圆形进度条 2.png|500px|无框|无|圆形进度条 2]] === 示例二 === {{codetab|tabs=<tabs><tab name="html"><syntaxhighlight lang="html5"> <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></syntaxhighlight></tab><tab name="css"><syntaxhighlight lang="css">.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); } } </syntaxhighlight></tab></tabs>}}
此页面嵌入的页面:
模板:Codetab
(
查看源代码
)
返回
CSS/进度条
。
导航菜单
康健生活
搜索
user-page
通知
user-interface-preferences
个人工具
登录
五一
多读书,多运动,多到远处走走,再看看不一样的世界。