简体   繁体   English

如何使CSS圆微调框的前缘半月形

[英]How to make leading edge of CSS circle spinner half moon shaped

Image: Circular spinner rotating along the border rim of other solid circle 图像: 圆形微调器沿其他实心圆的边界旋转

Please visit: https://codepen.io/sadashivjp/pen/oqqzwg I have create a UI codepen here. 请访问: https ://codepen.io/sadashivjp/pen/oqqzwg我已经在此处创建了UI Codepen。 You are free to make any changes in this, and post the solution here. 您可以对此进行任何更改,然后在此处发布解决方案。

The same code is as follows: 相同的代码如下:

 .outer-circle{ width:330px; height:330px; border:30px solid #001b33; position:absolute; top:0; bottom:0; left:0;right:0; margin:auto; border-radius:50%; } .spinner { animation: rotate 5s linear infinite; border-radius: 50%; height: 360px; width: 360px; position: relative; left: -15px; top: -15px; } .spinner:before, .spinner:after { content: ''; position: absolute; } .spinner:before { border-radius: 50%; background: linear-gradient(0deg, hsla(0, 0%, 100%, 0) 50%, hsla(0, 0%, 100%, 0.1) 100%) 0% 0%, linear-gradient(90deg, hsla(0, 0%, 100%, 0.1) 0%, hsla(0, 0%, 100%, 0.5) 100%) 100% 0%, linear-gradient(180deg, hsla(0, 0%, 100%, 0.5) 0%, hsla(0, 0%, 100%, 0.60) 100%) 100% 100%, linear-gradient(360deg, hsla(0, 0%, 100%, 0.60) 0%, hsla(0, 0%, 100%, 0.70 ) 100%) 0% 100% ; background-repeat: no-repeat; background-size: 50% 50%; top: -1px; bottom: -1px; left: -1px; right: -1px; } .spinner:after { background: black; border: 15px solid #001b33; border-radius: 50%; top: 3%; bottom: 3%; left: 3%; right: 3%; } @keyframes rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } 
 <div class="outer-circle"> <div class="spinner"></div> </div> 

There are two problems in this code: 1) It is causing wobbling(shaking) effect of spinner circle in IE11 browser. 此代码中有两个问题:1)它导致IE11浏览器中的微调器圆圈摆动(抖动)效果。 But, works perfect in Google chrome browser. 但是,可以在Google chrome浏览器中完美运行。 2) As in attached image, need the similar effect of half moon shaped(cylindrical bottom shaped) at the leading edge at the front of the inner white spinner circle. 2)如上图所示,在内部白色旋转器圆的前缘需要类似半月形(圆柱底形)的效果。

How to solve these two issues? 如何解决这两个问题? Modification of my existing code or providing solution with SVG or Canvas on any other would be fine. 修改我现有的代码或在其他任何代码上提供SVG或Canvas解决方案都可以。

Add a div inside your spinner. 在微调框内添加一个div。

 .outer-circle{ width:330px; height:330px; border:30px solid #001b33; position:absolute; top:0; bottom:0; left:0;right:0; margin:auto; border-radius:50%; } .spinner { animation: rotate 5s linear infinite; border-radius: 50%; height: 360px; width: 360px; position: relative; left: -15px; top: -15px; } .spinner:before, .spinner:after { content: ''; position: absolute; } .spinner:before { border-radius: 50%; background: linear-gradient(0deg, hsla(0, 0%, 100%, 0) 50%, hsla(0, 0%, 100%, 0.1) 100%) 0% 0%, linear-gradient(90deg, hsla(0, 0%, 100%, 0.1) 0%, hsla(0, 0%, 100%, 0.5) 100%) 100% 0%, linear-gradient(180deg, hsla(0, 0%, 100%, 0.5) 0%, hsla(0, 0%, 100%, 0.60) 100%) 100% 100%, linear-gradient(360deg, hsla(0, 0%, 100%, 0.60) 0%, hsla(0, 0%, 100%, 0.70 ) 100%) 0% 100% ; background-repeat: no-repeat; background-size: 50% 50%; top: -1px; bottom: -1px; left: -1px; right: -1px; } .spinner:after { background: black; border: 15px solid #001b33; border-radius: 50%; top: 3%; bottom: 3%; left: 3%; right: 3%; } @keyframes rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } .circle{ background: #b1bac1; width: 10px; height: 10px; position: absolute; top: 177px; bottom: 0; left: 0; right: 0; border-radius: 50% 50%; } 
 <div class="outer-circle"> <div class="spinner"> <div class="circle"> </div> </div> </div> 

 .outer-circle{ width:330px; height:330px; border:30px solid #001b33; position:absolute; top:0; bottom:0; left:0;right:0; margin:auto; border-radius:50%; } .spinner { animation: rotate 5s linear infinite; border-radius: 50%; height: 360px; width: 360px; position: relative; left: -15px; top: -15px; } .spinner:before,.spinner:after, .outer-circle:after { content: ''; position: absolute; } .spinner:before { border-radius: 50%; background: linear-gradient(0deg, hsla(0, 0%, 100%, 0) 50%, hsla(0, 0%, 100%, 0.1) 100%) 0% 0%, linear-gradient(90deg, hsla(0, 0%, 100%, 0.1) 0%, hsla(0, 0%, 100%, 0.5) 100%) 100% 0%, linear-gradient(180deg, hsla(0, 0%, 100%, 0.5) 0%, hsla(0, 0%, 100%, 0.60) 100%) 100% 100%, linear-gradient(360deg, hsla(0, 0%, 100%, 0.60) 0%, hsla(0, 0%, 100%, 0.70 ) 100%) 0% 100% ; background-repeat: no-repeat; background-size: 50% 50%; top: -1px; bottom: -1px; left: -1px; right: -1px; } .spinner:after{ background: #afb7bf; height: 15px; width:15px; border-radius: 50%; top: 175px; left: -1px; right: -100px; bottom: 0px; } .outer-circle:after { background: black; border: 15px solid #001b33; border-radius: 50%; top: -1px; bottom: -1px; left: -1px; right: -1px; } @keyframes rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } 
 <div class="outer-circle"> <div class="spinner"></div> </div> 

I hope this is the solution you are looking for! 我希望这是您正在寻找的解决方案!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM