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

flexbox doesnt show my numbers horizontally

enter image description here

Thought this would show the numbers 1,2,3,4 in the progress-container next to each other but it doesnt.
What am I missing here? Must be something wrong with my understanding of flexbox..

@import url("https://fonts.googleapis.com/css?family=Muli&display=swap");

* {
  box-sizing: border-box;
}

body {
  background-color: #f6f7fb;
  font-family: "Muli", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  overflow: hidden;
  margin: 0;
}

.container {
  text-align: center;
}

.progress-container {
  display: flex;
  justify-content: space-between;
  margin-bottom: 30px;
  max-width: 100%;
  width: 350px;
}


    <div class="container">
      <div class="progress-container">
        <div class="progress" id="progress">
          <div class="circle active">1</div>
          <div class="circle">2</div>
          <div class="circle">3</div>
          <div class="circle">4</div>
        </div>
      </div>


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

>Solution :

display: flex needs to be applied to the direct parent of the items that you want to be flex items. In your code, your flex container (.progress-container) has only one child (i.e. the #progress element), which doesn’t have much effect (and no effect on the grandchildren).

If you move the flex settings to the #progress element, it will work as desired:

@import url("https://fonts.googleapis.com/css?family=Muli&display=swap");
* {
  box-sizing: border-box;
}

body {
  background-color: #f6f7fb;
  font-family: "Muli", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  overflow: hidden;
  margin: 0;
}

.container {
  text-align: center;
}

.progress-container {
  margin-bottom: 30px;
  max-width: 100%;
  width: 350px;
}

#progress {
  display: flex;
  justify-content: space-between;
}
<div class="container">
  <div class="progress-container">
    <div class="progress" id="progress">
      <div class="circle active">1</div>
      <div class="circle">2</div>
      <div class="circle">3</div>
      <div class="circle">4</div>
    </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