-2

I am new to using flex. My problem is to design a site page. I want to put a div tag in the center of the web page using flex. Thank you for your help.

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
  • Please read [ask] and [mcve]. We suppose you make some research before asking her, if you serach on SO you will find a lot of answer about centering elements with flexbox – Sfili_81 Jan 13 '21 at 13:30

2 Answers2

-1

To fix this add to the parent element display: flex; justify-content: space-around;

Nick
  • 76
  • 7
-1

.container{
  width: 100%;
  height: 100vh;
  background: red;
  display: flex;
  align-items: center;
  justify-content: center
}

.centered{
  width: 100px;
  height: 100px;
  background: green;
  
}
<div class="container">
    <div class="centered">
        This is in the center
    </div>
</div>