Skip to main content

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 
  1. border-bottom-color:black
  2. 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)
  }

Hope you find it useful 😘

Follow my socials:

Youtube:https://www.youtube.com/channel/UCU1qNFntn7dCi9uqyvrGKOg

Instagram: https://www.instagram.com/python.math/

Twitter:https://twitter.com/Pritish369

For any question or coding discussion, you can join my discord or telegram:

Discord:https://discord.gg/be7MmSuV

Telegram:https://t.me/Python_Math_Community

Comments

Popular posts from this blog

Create Ping Pong Game in Python

  Ping Pong Game: Table tennis , also known as  ping-pong  and  whiff-whaff , is a sport in which two or four players hit a lightweight ball, also known as the ping-pong ball, back and forth across a table using small rackets. The game takes place on a hard table divided by a net. Except for the initial serve, the rules are generally as follows: players must allow a ball played toward them to bounce once on their side of the table and must return it so that it bounces on the opposite side at least once. A point is scored when a player fails to return the ball within the rules. Play is fast and demands quick reactions. Spinning the ball alters its trajectory and limits an opponent's options, giving the hitter a great advantage. We can make it using pygame but I keep it more simple we will create this game using only the turtle module so let's drive into the code without wasting any time Code: # Import required library import turtle # Create screen sc = turtle . Screen () sc .

Draw Minecraft Charater in Python

  Minecraft  is a  sandbox video game  developed by the Swedish video game developer  Mojang Studios . The game was created by  Markus "Notch" Persson  in the  Java programming language . Following several early private testing versions, it was first made public in May 2009 before fully releasing in November 2011, with  Jens Bergensten  then taking over development.  Minecraft  has since been ported to several other platforms and is the  best-selling video game of all time , with over 238 million copies sold and nearly 140 million  monthly active users  as of 2021 . We gonna build a character of Minecraft using our creativity and coding skills so let's drive into the code: Code: import turtle as t def eye ( r , a ):     t . fillcolor ( 'brown' )     t . begin_fill ()     t . circle ( r , a )     t . end_fill () t . begin_fill () t . fillcolor ( '#8a00e6' ) t . penup () t . goto ( 0 ,- 50 ) t . pendown () t . right ( 90 ) t . f

How To Draw BMW Logo - In Python

 I know I don't need to introduce BMW as it is a very popular luxury car. Today we gonna draw the BMW logo in python. I know that you can draw it using a pencil and other tools like AutoCAD etc. But we are programmers we talk with computers so let's tell our computer to draw this logo for use with the help of python. Module The only module we will use is that turtle Code: import turtle as t t.begin_fill() t.fillcolor( '#008ac9' ) for i in range ( 50 ):     t.forward( 4 )     t.left( 2 ) t.right(- 80 ) t.forward( 116 ) t.right(- 90 ) t.forward( 132 ) t.end_fill() t.penup() t.pendown() t.right( 90 ) for i in range ( 50 ):     t.forward( 4 )     t.left(- 2 ) t.right( 80 ) t.forward( 116 ) t.forward(- 116 ) t.right( 90 ) t.begin_fill() t.fillcolor( '#008ac9' ) for j in range ( 45 ):     t.forward(- 4 )     t.left(- 2 ) t.right(- 90 ) t.forward( 116 ) t.end_fill() t.right( 180 ) t.forward( 116 ) t.right( 90 ) for i in range ( 47 ):     t.forward( 4 )     t.