DEV Community

loading...

How to make parent div expand to children element width?

nehalahmadkhan profile image Nehal Ahmad ・1 min read

I am using Bootstrap and trying to create a horizontal scroll list using row, columns, and flex-no-wrap as following.

    <div class="row bg-primary flex-nowrap p-3">
        <h2 class="col-6">Lorem, ipsum dolor.</h2>
        <h2 class="col-6">Lorem, ipsum dolor.</h2>
        <h2 class="col-6">Lorem, ipsum dolor.</h2>
        <h2 class="col-6">Lorem, ipsum dolor.</h2>
    </div>
Enter fullscreen mode Exit fullscreen mode

But parent div only takes the width of the screen and does not expand beyond that like children columns. Does anyone know to fix it?
ezgif.com-gif-maker

Discussion (0)

pic
Editor guide