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">
    <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" />
    <div class="container">
      <div class="box box-one">A</div>
      <div class="box">B</div>
      <div class="box">C</div>
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)

50 CLI Tools You Can't Live Without

The top 50 must-have CLI tools, including some scripts to help you automate the installation and updating of these tools on various systems/distros.