Build a Ship Using Only CSS || CSS Animation Project || CSS Design Code || Modern CSS Design - Creation Code
Build a Ship Using Only CSS
CSS is a tool for web designers to be unique by creating unique designs and patterns in a website. You can master CSS by creating unique projects and practicing a lot. In this post, we will build a ship using only CSS.
#img1
Explanation:
This is our project, we are going to build this project. Now you can create it very easily. If you look at the img1 then you can find that the hole design is based on squares and lines.
#img2
The top part(ship) and the body(body1 and body2) of the ship is basically boxes so our idea is to build this using the border property of CSS.
Using border and giving these it some height and width we can create these boxes very easily. But if we create these boxes then we need to minus the bottom part of the boxes it can be done by
- border-bottom-color:black
- border-bottom:none
You can choose any of the above
div.ship{
border-width:10px;
height:44px;
width:80px;
margin-left:150px;
margin-top:100px;
border-bottom-width:5px;
border-bottom-color:#191919
}
The second part is the body of the ship. For this, we will create the same box and in this case we need to minus the bottom part and right border. After this, we will use the transform method for rotating the box,
div.body{
position:absolute;
height:26px;
width:80px;
margin-left:125px;
border-right:none;
border-bottom:transparent;
transform:rotate(-30deg);
background:transparent;
top:80px;
}
Full Code:
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Ship</title>
</head>
<body>
<div class="window">
<div class="ship"></div>
<div class="body"></div>
<div class="body1"></div>
<p class="line"></p>
<p class="line1"></p>
<p class="line2"></p>
</div>
</body>
</html>
CSS:
*{
margin:0px;
padding:0px;
background:#191919;
}
div.window{
display: flex;
position:absolute;
width: 400px;
height: 300px;
}
div {
margin-left:175px;
background:#191919;
border-width:10px;
border-style:solid;
border-color:#5DBCF9;
height:20px;
width:30px;
margin-top:66px
}
div.ship{
border-width:10px;
height:44px;
width:80px;
margin-left:150px;
margin-top:100px;
border-bottom-width:5px;
border-bottom-color:#191919
}
div.body{
position:absolute;
height:26px;
width:80px;
margin-left:125px;
border-right:none;
border-bottom:transparent;
transform:rotate(-30deg);
background:transparent;
top:80px;
}
div.body1{
position:absolute;
height:26px;
width:80px;
margin-left:184px;
border-left:none;
border-bottom:transparent;
transform:rotate(30deg);
background:transparent;
top:80px;
}
p.line{
border-left: 10px solid #5DBCF9;
height: 65px;
position: absolute;
left: 50%;
margin-left:-5px;
top: 130px;
}
p.line1{
border-left: 10px solid #5DBCF9;
height: 110px;
position: absolute;
left: 50%;
margin-left:-5px;
top: 180px;
transform:rotate(90deg)
}
p.line2{
border-left: 10px solid #5DBCF9;
height: 200px;
position: absolute;
left: 50%;
margin-left:-5px;
top: 100px;
transform:rotate(90deg)
}
Comments
Post a Comment