在前端开发中,制作一个吊扇的布局通常涉及到HTML、CSS,甚至可能包括一些JavaScript来添加交互效果。以下是一个简单的吊扇布局示例:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>吊扇布局</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="ceiling-fan">
<div class="fan-base"></div>
<div class="fan-blades">
<div class="blade"></div>
<div class="blade" style="transform: rotate(72deg);"></div>
<div class="blade" style="transform: rotate(144deg);"></div>
<div class="blade" style="transform: rotate(216deg);"></div>
<div class="blade" style="transform: rotate(288deg);"></div>
</div>
</div>
</body>
</html>
CSS (styles.css)
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f5f5f5;
}
.ceiling-fan {
position: relative;
width: 200px;
height: 200px;
}
.fan-base {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 50px;
background-color: #888;
border-radius: 50%;
}
.fan-blades {
position: absolute;
top: 50px; /* Adjust this to position the blades correctly */
left: 0;
width: 100%;
height: 150px; /* Adjust this based on the blade length */
}
.blade {
position: absolute;
left: 50%; /* Center the blade horizontally */
bottom: 0; /* Start from the bottom */
width: 20px; /* Blade width */
height: 100%; /* Blade length */
background-color: #555;
transform-origin: bottom center; /* Rotate from the bottom center */
}
这个示例创建了一个简单的吊扇布局,包括一个底座和五个均匀分布的扇叶。你可以根据需要调整CSS中的尺寸、颜色和位置。如果你想要添加动画效果,比如让扇叶旋转,你可以使用CSS动画或JavaScript来实现。
添加旋转动画(可选)
如果你想让扇叶旋转起来,可以在CSS中添加一个简单的动画:
@keyframes rotateFan {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.fan-blades {
animation: rotateFan 5s linear infinite; /* Adjust the duration as needed */
}
标签:布局,height,width,fan,position,吊扇,制作,CSS
From: https://www.cnblogs.com/ai888/p/18621690