Home > database >  Bootstrap 5 Column Stacking Depending on Width
Bootstrap 5 Column Stacking Depending on Width

Time:09-17

I have HTML like:

    <div class="container-fluid">
        <div class="row">
            <div class="col-9">
                <div class="container">...</div>
            </div>
            <div class="col-3">
               <div class="container">...</div>
            </div>
        </div>
    </div>

I am trying to get it so that, once a certain threshold of viewport width is reached, the columns stacked. I thought this was achievable by specifying col-xs-12 col-sm-12 col-md-9 col-lg-9... for the first col and corresponding ones (3, 12, 12, ...) for the second.

This is not working however.

My head Bootstrap link is:

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

CodePudding user response:

Try to use col-12 col-md-9.

Bootstrap is "mobile first", so the above code means: by default this element is col-12 (full-width), then from medium up it will be 3/4 of the row element col-md-9.

  • Related