Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap4: Placing Cards side by side?

Tags:

bootstrap-4

So I am using bootstrap4. I'm trying to place one card on the left of two other cards that are stacked on top of each other, with the left most card having a set length of the total length of the other two cards....But I can't figure out how to do this.

<div class="card w-20">
    <blockquote class="blockquote card-body">
        <p>This card on the left of the other two cards, with a fixed height and scrolling.</p>
        <footer class="blockquote-footer">
            <small class="text-muted">
                Someone famous in <cite title="Source Title">Source Title</cite>
            </small>
        </footer>
    </blockquote>
</div>
<div class="card w-75">
    <div class="card-body">
        <h5 class="card-title">How do you want to ask the question?</h5>
        <p class="card-text">Enter the information below.</p>
        <div class="input-group">
            <div class="input-group-prepend">
                <span class="input-group-text">Description</span>
            </div>
            <textarea class="form-control" aria-label="With textarea"></textarea>
        </div>
        <div class="input-group">
            <div class="input-group-prepend">
                <span class="input-group-text">Supplemental Methods</span>
            </div>
            <button type="button" class="btn btn-outline-dark m-3">Text</button>
            <button type="button" class="btn btn-outline-dark m-3">Audio</button>
            <button type="button" class="btn btn-outline-dark m-3">Video</button>
            <button type="button" class="btn btn-outline-dark m-3">Image</button>						 
        </div>
        <button type="button" class="btn btn-outline-dark m-3 float-right">Next</button>						 
    </div>
</div>
<div class="card w-75">
    <div class="card-body">
        <h5 class="card-title">How should students ask the question?</h5>
        <p class="card-text">Enter the information below.</p>
        <div class="input-group text-center">
            <button type="button" class="btn btn-outline-dark m-3">Audio</button>
            <button type="button" class="btn btn-outline-dark m-3">Video</button>
            <button type="button" class="btn btn-outline-dark m-3">Short Answer</button>
            <button type="button" class="btn btn-outline-dark m-3">Sorting</button>						 
        </div>
        <div class="input-group mx-auto">
            <button type="button" class="btn btn-outline-dark m-3">T/F</button>
            <button type="button" class="btn btn-outline-dark m-3">Matching</button>
            <button type="button" class="btn btn-outline-dark m-3">Label</button>
            <button type="button" class="btn btn-outline-dark m-3">Multiple Choice</button>						 
        </div>
        <button type="button" class="btn btn-outline-dark m-3 float-right">Next</button>					
    </div>
</div>
like image 370
sGlow Avatar asked Mar 07 '23 03:03

sGlow


1 Answers

For this kind of layout you should use the grid, not utility classes:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<div class="container">
    <div class="row">
        <div class="col col-md-3">
            <div class="card h-100">
                <p class="card-body">This card on the left of the other two cards, with a fixed height and scrolling.</p>
            </div>
        </div>
        <div class="col col-md-9">
            <div class="card">
                <p class="card-body">How do you want to ask the question?<p>
            </div>
            <div class="card">
                <p class="card-body">How should students ask the question?</p>
            </div>
        </div>
    </div>
</div>
like image 145
tobib Avatar answered Apr 26 '23 22:04

tobib