DEV Community

Tshilidzi Rambuda
Tshilidzi Rambuda

Posted on

3 3

Simple flexbox tutorial

How to style multiple blocks of different colors in one single row and get what we call a color palette out of it?

In this tutorial I will show you how you can style multiple blocks of different colors and make a color palette using css property flexbox.

Fist we will start by creating a div container that will contain five divs with different colors.

This is how our html will look like

<div class="container">
   <div></div>
   <div></div>
   <div></div>
   <div></div>
   <div></div>
</div>
Enter fullscreen mode Exit fullscreen mode

And this is the css code below

.container{
  width:100%;
  max-width:1000px;
  height: 200px;
  display: flex;
  flex-direction:row;
  justify-content:space-evenly;
}
.container > div{
  width:calc(100%/5);
  height:100%;
}
.container > div:nth-child(1){
  Background:blue;
}
.container > div:nth-child(2){
  Background:lightblue;
}
.container > div:nth-child(3){
  Background:red;
}
.container > div:nth-child(4){
  Background:lightred;
}
.container > div:nth-child(5){
  Background:pink;
}
Enter fullscreen mode Exit fullscreen mode

And that is how you create a css flexbox color palette guys :)

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay