css小船制作
CSS小船制作方法
使用纯CSS可以创建简洁的小船图形,主要利用border、transform和position等属性实现。以下是两种常见的小船样式实现方式:
基础小船样式
HTML结构:
<div class="boat"></div>
CSS代码:
.boat {
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 100px solid #8B4513;
position: relative;
}
.boat:after {
content: "";
position: absolute;
left: -30px;
top: -60px;
width: 60px;
height: 120px;
background: #FFD700;
transform: rotate(15deg);
}
带波浪效果的船
HTML结构:
<div class="boat-container">
<div class="boat"></div>
<div class="wave"></div>
</div>
CSS代码:
.boat-container {
position: relative;
width: 200px;
height: 200px;
}
.boat {
width: 120px;
height: 60px;
background: #8B4513;
border-radius: 10px 10px 50% 50%;
position: absolute;
bottom: 40px;
left: 40px;
}
.boat:before {
content: "";
position: absolute;
width: 10px;
height: 80px;
background: #A0522D;
left: 55px;
top: -80px;
}
.boat:after {
content: "";
position: absolute;
width: 60px;
height: 40px;
background: #F5DEB3;
border-radius: 5px;
left: 30px;
top: 10px;
}
.wave {
width: 200px;
height: 40px;
background: #1E90FF;
border-radius: 50%;
position: absolute;
bottom: 0;
}
动画效果增强
可以为小船添加浮动动画:
@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-10px); }
}
.boat {
animation: float 3s ease-in-out infinite;
}
响应式调整
通过媒体查询调整小船大小:

@media (max-width: 600px) {
.boat {
transform: scale(0.7);
}
}
这些CSS技巧组合可以创建从简单到复杂的小船视觉效果,通过调整颜色、尺寸和形状参数可获得不同风格的设计。






