DEV Community

Ahtsham Ajus
Ahtsham Ajus

Posted on

Today I learned about Flex Box and Floating elements

Here's my HTML code.

<!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" />
    <title>Flex Box</title>
    <link rel="stylesheet" href="./style.css" />
  </head>
  <body>
    <div class="container">
      <div class="box box-one">A</div>
      <div class="box">B</div>
      <div class="box">C</div>
    </div>
  </body>
</html>
Enter fullscreen mode Exit fullscreen mode

Here's my CSS code.

body {
    margin: 10px;
}
.container {
    border: 3px solid lightpink;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    height: 90vh;


}
.box {
    flex-basis: 15rem;
    flex-grow: 1;
    flex-shrink: 1;
    flex: 1 1 15rem;
    width: 5rem;
    height: 5rem;
    background: lightsalmon;
    margin: 1rem;
}
.box-one {
    flex-basis: 5rem;
    align-self: center;

}
Enter fullscreen mode Exit fullscreen mode

Here's the output
Alt Text

Top comments (0)