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>
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>