Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

justify-content is not working when div is wrapped in 'flex' parent container

I have a container that has been set ‘flex’ but I am now trying to pass ‘justify-content: space-evenly’ to the button container but it doesn’t seem to work. Any ideas?

.full-width {
  width: 100%;
}

.banner__container {
  display: flex;
  justify-content: space-evenly;
  background-color: #f6f6f6;
}

.button__container {
  display: flex;
  justify-content: space-evenly;
}
<div class="full-width">
  <div class="banner__container">
    <div>
      <p>
        Lorem
      </p>
    </div>
    <div class="button__container">
      <a href="">Yes</a>
      <a href="">No</a>
      <button>Close</button>
    </div>
  </div>
</div>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Everything is working fine. You just have to set a proper flex value to the child divs of .banner__container.

I have done that by setting flex: 1; to .banner__container div. This will give equal width for each divs inside .banner__container

.full-width {
    width: 100%;
}

.banner__container {
    display: flex;
    justify-content: space-evenly;
    background-color: #f6f6f6;
}

.banner__container div {
    flex: 1;
}

.button__container {
    display: flex;
    justify-content: space-evenly;
}
<div class="full-width">
    <div class="banner__container">
        <div>
            <p>
                Lorem
            </p>
        </div>
        <div class="button__container">
            <a href="">Yes</a>
            <a href="">No</a>
            <button>Close</button>
        </div>
    </div>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading