css实现可摇头调风速电风扇效果代码
代码语言:html
所属分类:动画
代码描述:css实现可摇头调风速电风扇效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS 可控电风扇</title>
<style>
:root {
--fan-color: #e0e0e0;
--blade-color: #3498db;
--cage-color: #bdc3c7;
--speed: 0s; /* 0s 表示停止 */
--swing-state: paused; /* 默认不摇头 */
}
body {
margin: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: #2c3e50;
font-family: sans-serif;
}
.fan-container {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
}
/* === 风扇头部 (包含网罩和扇叶) === */
.fan-head {
width: 220px;
height: 220px;
position: relative;
z-index: 10;
animation: swing 4s ease-in-out infinite alternate;
animation-play-state: var(--swing-state);
transform-origin: center 280px; /* 摇摆轴心在底座上方 */
}
/* 网罩 */
.cage {
width: 100%;
height: 100%;
border-radius: 50%;
border: 4px solid var(--cage-color);
box-shadow: 0 0 10px rgba(0,0,0,0.2);
position: relative;
background:
.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0