首页 话题 小组 问答 好文 用户 我的社区 域名交易 唠叨

[分享]css做海盗船

发布于 2024-11-11 15:54:44
0
15

CSS做海盗船要用CSS实现一艘海盗船,需要掌握一些基础知识和技巧。首先,我们可以利用CSS实现一个方形的船体,代码如下:.boat { width: 200px; height: 100px; ba...

CSS做海盗船

要用CSS实现一艘海盗船,需要掌握一些基础知识和技巧。

首先,我们可以利用CSS实现一个方形的船体,代码如下:

.boat {
  width: 200px;
  height: 100px;
  background-color: #645A4F;
} 

接着,加上三角形的帆,代码如下:

.boat::before {
  content: "";
  width: 0;
  height: 0;
  border-bottom: 100px solid #645A4F;
  border-right: 100px solid transparent;
  position: absolute;
  top: -50px;
  left: -100px;
}

.boat::after {
  content: "";
  width: 0;
  height: 0;
  border-top: 50px solid transparent;
  border-right: 100px solid #645A4F;
  position: absolute;
  top: 50px;
  left: -100px;
} 

这样,我们就有了一艘具有形体的海盗船。

可以继续添加舵和桨,代码如下:

.boat .rudder {
  width: 50px;
  height: 50px;
  background-color: #645A4F;
  position: absolute;
  top: 45px;
  right: -50px;
  transform: rotate(45deg);
}

.boat .oar {
  width: 10px;
  height: 80px;
  background-color: #645A4F;
  position: absolute;
  bottom: -40px;
  left: 50px;
  transform: rotate(135deg);
}

.boat .oar::before {
  content: "";
  width: 10px;
  height: 10px;
  background-color: #645A4F;
  position: absolute;
  bottom: -10px;
  left: 0;
  border-radius: 50%;
} 

这样,一艘基本的海盗船就完成了,通过改变颜色和细节的渐进变化,可以让其具有更丰富的表现和内涵。

评论
一个月内的热帖推荐
91云脑
Lv.1普通用户

62849

帖子

14

小组

291

积分

赞助商广告
站长交流