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

* HTML 5Bootstrap* CSS flex

Avatar of undefined
Last Comment
mike99c

8/22/2022 - Mon