Why a space exists between the last row and the second last row?

Viewed 70

I am using bootstrap to create a table, my code as the following:

    <html>
        <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
            <title>WebRTC Caller</title>
            <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
            <style>
                video{
                    transform: scale(-1, 1);
                    object-fit:cover;
                }
            </style>
            <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
            <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
            <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
        </head>
        <body class="p-1">
            <div class="border-top border-primary container-fluid">
                <div class="row h-25">
                    <div class="col-6 border-left border-bottom border-primary">
                    </div>
                    <div class="col-6 border-left border-bottom border-right border-primary">
                    </div>
                </div>
                <div class="row h-25">
                    <div class="col-12 border-left border-bottom border-right border-primary">
                        dssdf
                    </div>
                </div>
                <div class="row h-25">
                    <div class="col-12 border-left border-bottom border-right border-primary overflow-auto h3">
                        fda
                    </div>
                </div>          
                <div class="row h-25">
                    <div class="col-12 h-100 border-left border-bottom border-right border-primary overflow-auto h3">
                        e
                    </div>
                </div>
            </div>
        </body>
    </html> 

My problem is that why space exists between the last row and the second last row. I found that if I remove the h3 class from the last 2 rows, the problem has vanished. However, I need the h3 class to make the web page can be readable on the mobile phone.

So, how can I fix the problem?

4 Answers

Just add margin 0 class m-0.

<div class="row h-25">
    <div class="col-12 border-left border-bottom border-right border-primary overflow-auto h3 m-0" style="">
         fda
    </div>
</div>

It is due to class .h3:

.h3{
   margin-bottom: .5rem;
}

You can fix with a mb-0 override:

    <html>
        <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
            <title>WebRTC Caller</title>
            <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
            <style>
                video{
                    transform: scale(-1, 1);
                    object-fit:cover;
                }
            </style>
            <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
            <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
            <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
        </head>
        <body class="p-1">
            <div class="border-top border-primary container-fluid">
                <div class="row h-25">
                    <div class="col-6 border-left border-bottom border-primary">
                    </div>
                    <div class="col-6 border-left border-bottom border-right border-primary">
                    </div>
                </div>
                <div class="row h-25">
                    <div class="col-12 border-left border-bottom border-right border-primary">
                        dssdf
                    </div>
                </div>
                <div class="row h-25">
                    <div class="col-12 border-left border-bottom border-right border-primary overflow-auto h3 mb-0">
                        fda
                    </div>
                </div>          
                <div class="row h-25">
                    <div class="col-12 h-100 border-left border-bottom border-right border-primary overflow-auto h3">
                        e
                    </div>
                </div>
            </div>
        </body>
    </html> 

Upon doing an Inspect on the page, i found a small bottom margin on the second last row of 0.5rem.

Overriding this CSS property in Bootstrap solves the problem by adding mb-0.

m = margin, b = bottom

<div class="row h-25">
   <div class="col-12 border-left border-bottom border-right border-primary overflow-auto h3 mb-0">
       fda
   </div>
</div>
margin-top: 0;

this would most probably help you to get rid of the space between the two rows, as it is supposed to remove the margin [space] at the top between them.

Related