DEV Community

Nehal Ahmad
Nehal Ahmad

Posted on

How to make parent div expand to children element width?

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

Top comments (0)