Link to home
Create AccountLog in
Avatar of mike99c
mike99c

asked on

How can I use Bootstrap 4 Flexbox to right align 2 inline divs out of 3

I'm using Bootstrap 4 to right align 3 divs using flex-row. However in the code example given below, I would like to adjust it so that flex item 2 and flex item 3 are right aligned,
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Flexbox Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>

<body>

    <div class="container mt-3">
        <h1>Horizontal Direction</h1>

        <div class="d-flex flex-row bg-secondary">
            <div class="p-2 bg-info">Flex item 1</div>
            <div class="p-2 bg-warning">Flex item 2</div>
            <div class="p-2 bg-primary">Flex item 3</div>
        </div>
    </div>

</body>

</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of mike99c
mike99c

ASKER

That's perfect thanks so much. I hadn't come across the justify-content classes but this is very useful. So it appears to justify it around the empty columns.