css 光点环绕旋转
时间: 2024-01-05 07:20:14 浏览: 44
以下是一种实现CSS光点环绕旋转效果的方法:
```html
<!DOCTYPE html>
<html>
<head>
<style>
.container {
position: relative;
width: 200px;
height: 200px;
margin: 0 auto;
perspective: 1000px;
}
.circle {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 150px;
height: 150px;
border-radius: 50%;
background-color: #000;
animation: rotate 5s linear infinite;
}
@keyframes rotate {
0% {
transform: translate(-50%, -50%) rotate(0deg);
}
100% {
transform: translate(-50%, -50%) rotate(360deg);
}
}
.dot {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 10px;
height: 10px;
border-radius: 50%;
background-color: #fff;
animation: orbit 5s linear infinite;
}
@keyframes orbit {
0% {
transform: translate(-50%, -50%) rotate(0deg) translateX(75px) rotate(0deg);
}
100% {
transform: translate(-50%, -50%) rotate(360deg) translateX(75px) rotate(-360deg);
}
}
</style>
</head>
<body>
<div class="container">
<div class="circle"></div>
<div class="dot"></div>
</div>
</body>
</html>
```
这段代码创建了一个容器,其中包含一个圆环和一个光点。圆环通过`animation`属性实现了旋转效果,光点通过`animation`属性实现了绕圆环旋转的效果。通过调整`translateX`和`rotate`的值可以控制光点的位置和旋转方向。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)