gpt4 book ai didi

javascript - 使美丽的微调器的中心透明

转载 作者:行者123 更新时间:2023-12-04 03:42:20 25 4
gpt4 key购买 nike

这是网上最好的装载机之一:

*{
margin: 0;
padding: 0;
box-sizing: border-box;
}

body{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: white;
}

.container{
positition: relative;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}

.container .loader{
position: relative;
width: 200px;
height: 200px;
border-radius: 50%;
background-color: #424242;
animation: animate 1s linear infinite;
}

@keyframes animate{
0%{
transform: rotate(0deg);
}
100%{
transform: rotate(360deg);
}
}

.container .loader::before{
content: '';
position: absolute;
top: 0;
left: 0;
width: 50%;
height: 100%;
background: linear-gradient(to top, transparent, dodgerblue);
background-size: 100px 180px;
background-repeat: no-repeat;
border-top-left-radius: 100px;
border-bottom-left-radius: 100px;
}

.container .loader::after{
content: '';
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
width: 10px;
height: 10px;
background-color: #00B0FF;
border-radius: 50%;
z-index: 10;
box-shadow: 0 0 10px #00B0FF,
0 0 20px #00B0FF,
0 0 30px #00B0FF,
0 0 40px #00B0FF,
0 0 50px #00B0FF,
0 0 60px #00B0FF,
0 0 70px #00B0FF,
0 0 80px #00B0FF,
0 0 90px #00B0FF,
0 0 100px #00B0FF;
}

.container .loader span{
position: absolute;
top: 10px;
left: 10px;
right: 10px;
bottom: 10px;
border-radius: 50%;
background-color: #212121;
}
<div class="container">
<div class="loader">
<span></span>
</div>
</div>

我想修改代码或找到一个解决方案来消除中心的黑色背景并使其透明,同时微调器保持不变但是当我从 container .loader span 中删除背景色时> 旋转器完全损坏。有没有什么办法可以实现和透明中心一样的旋转效果?

最佳答案

您可以像下面这样对 before 元素应用 mask

 mask: radial-gradient(farthest-side at right, transparent calc(100% - 10px), #fff 0);

这将只保留边框可见,您可以摆脱所有背景

body{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin:0;
background:linear-gradient(to right,grey,transparent);
}
.loader{
position: relative;
width: 150px;
height: 150px;
border-radius: 50%;
animation: animate 1s linear infinite;
}

@keyframes animate{
100%{
transform: rotate(360deg);
}
}

.loader::before{
content: '';
position: absolute;
top: 0;
left: 0;
width: 50%;
height: 100%;
background: linear-gradient(to top, transparent, dodgerblue) no-repeat;
background-size: 100% 80%;
border-radius: 100px 0 0 100px;
-webkit-mask: radial-gradient(farthest-side at right, transparent calc(100% - 10px), #fff 0);
}


.loader::after{
content: '';
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
width: 10px;
height: 10px;
border-radius: 50%;
z-index: 10;
box-shadow: 0 0 10px #00B0FF,
0 0 20px #00B0FF,
0 0 30px #00B0FF,
0 0 40px #00B0FF,
0 0 50px #00B0FF,
0 0 60px #00B0FF,
0 0 70px #00B0FF,
0 0 80px #00B0FF,
0 0 90px #00B0FF,
0 0 100px #00B0FF;
}
<div class="loader"></div>

或者像下面这样保留圆形边框:

body{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin:0;
background:linear-gradient(to right,grey,transparent);
}
.loader{
position: relative;
width: 150px;
height: 150px;
border-radius: 50%;
animation: animate 1s linear infinite;
}

@keyframes animate{
100%{
transform: rotate(360deg);
}
}

.loader::before{
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(to top, transparent, dodgerblue) no-repeat lightgrey;
background-size: 50% 80%;
border-radius: 50%;
-webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 10px), #fff 0);
}


.loader::after{
content: '';
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
width: 10px;
height: 10px;
border-radius: 50%;
z-index: 10;
box-shadow: 0 0 10px #00B0FF,
0 0 20px #00B0FF,
0 0 30px #00B0FF,
0 0 40px #00B0FF,
0 0 50px #00B0FF,
0 0 60px #00B0FF,
0 0 70px #00B0FF,
0 0 80px #00B0FF,
0 0 90px #00B0FF,
0 0 100px #00B0FF;
}
<div class="loader"></div>

关于javascript - 使美丽的微调器的中心透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65765829/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com