Quantcast
Channel: Active questions tagged flexbox - Stack Overflow
Viewing all articles
Browse latest Browse all 1617

justify content in flex layout is not centering text

$
0
0

I have a simple box with text inside (Image available below). I'm trying to center the text using justify-content: center, but it's not working even though there is space available. I know text-align: center will do the job, but I want to understand why justify-content isn't behaving as I'd expect.

Image showing the box and the text inside

.box {  background-color: aquamarine;  width: 300px;  height: 300px;  display: flex;  justify-content: center;    /* doesn't center */  /* text-align: center; */   /* this will center */}
<div class="box"><div class="text">Hello I'm Here lets go</div>   </div>

Viewing all articles
Browse latest Browse all 1617

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>