I’m trying to arrange a set of divs that look like this:
<div class="productionList">
<div>
<img>
<progress>
</div>
</div>
inside of a larger div (.productionList)
but no matter what i try they each get their own line:
…
although i want it to look like this:
[—img–][—img–][—img–][—img–][—img–][—img–]…
[progress][progress][progress][progress][progress][progress]…
(wrap once it reaches end of container)
[—img–][—img–]
[progress][progress]
This is what my css code looks like:
.productionList {
border: 1px solid white;
width: 100%;
}
.productionList div {
width: 40px;
}
.productionList div img {
width: 100%;
}
.productionList div progress {
width: 100%;
}
any idea what’s going on or how to fix this?
for reproduction
<style>
.productionList {
border: 1px solid white;
width: 100%;
}
.productionList div {
width: 40px;
}
.productionList div img {
width: 100%;
}
.productionList div progress {
width: 100%;
}
</style>
<div class="productionList">
<div>
<img>
<progress>
</div>
<div>
<img>
<progress>
</div>
<div>
<img>
<progress>
</div>
</div>
2
Answers
To get the children
<div>
of.productionList
aligned horizontally, you’ll want to usedisplay: flex;
.flex-wrap: wrap;
wraps them to the next line.You can learn more about them from W3Schools.
You need a
display: inline-block;
inside your divs that contain the image and the progress: