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.
Asked
Active
Viewed 81 times
-2
-
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 Answers
-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>

Osama Jandali
- 144
- 4