How to structure the layout of a dashboard using Bootstrap?

Viewed 32

I'm interested in creating a dashboard using the Bootstrap grid system. I'd like the layout to look as follows:

enter image description here

What is the best way to structure this in the HTML file? Should it be 5 rows and 2 columns?

Here is my attempt:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
</head>
<body>
    <div class="container-fluid">
        <div class="row">
            <div class="col-3 d-flex justify-content-center">
                <img src="foo.png" alt="Box 1">
            </div>
            <div class="col-9">
                Box 2
            </div>
        </div>

        <div class="row">
            <div class="col-2">
                Box 3
            </div>
            <div class="col-2">
                Box 3
            </div>
        </div>

        <div class="row">
            <div class="col-4">
                <div>
                    <table>
                        Box 4
                    </table>
                </div>
                <div>
                    <table>
                        Box 5
                    </table>
                </div>
            </div>

            <div class="col-8">
                Box 6
            </div>
        </div>
        <div class = "row">
            <div class="col-12 d-flex justify-content-center">
                Box 7
            </div>
        </div>
    </div>

</body>
</html>

Any assistance would be most appreciated!

Thanks!

1 Answers

4 rows, two inner rows on row 3 for the left box 4 and box 5.

And then you specify the css inside each box, like alignment and height etc. But the 2 columns in row 3 containing box 4, 5 and 6 are on the same row, for the gap in between, just specify blank columns but make sure they always add up to 12.

.box {
  border-style: dotted;
  margin-top: 10px;
  margin-bottom: 10px;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
</head>
<body>
    <div class="container-fluid">
        <!--Row 1-->
        <div class="row">
            <div class="col-3">
                <div class="box">
                  Box 1 (Image)
                </div>
            </div>
            <div class="col-1">
                
            </div>
            <div class="col-8">
                <div class="box">
                  Box 2 (Text)
                </div>
            </div>
        </div>

        <!--Row 2-->
        <div class="row">
            <div class="col-4">

            </div>
            <div class="col-4">
                <div class="box">
                  Box 3
                </div>
            </div>
            <div class="col-4">

            </div>
        </div>

        <!--Row 3-->
        <div class="row">
            <div class="col-4">
                <!--Row 3.1-->
                <div class="row">
                  <div class="col-12">
                    <div class="box">
                      Box 4 (Table)
                    </div>
                  </div>
                </div>
                <!--Row 3.2-->
                <div class="row">
                  <div class="col-12">
                    <div class="box">
                      Box 5 (Table)
                    </div>
                  </div>
                </div>
            </div>
            <div class="col-1">
                
            </div>
            <div class="col-7">
                <div class="box">
                  Box 6 (Chart)
                </div>
            </div>
        </div>
        
        <!--Row 4-->
        <div class = "row">
            <div class="col-12">
                <div class="box">
                  Box 7 (Table)
                </div>
            </div>
        </div>
    </div>

</body>
</html>

Related