Link to home
Create AccountLog in
Avatar of 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">

    <title>Flexbox Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="">
    <script src=""></script>
    <script src=""></script>


    <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>



Open in new window

Avatar of Bill Prew
Bill Prew

Link to home
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


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.