Fixed bootstrap height pre-scrolling div

In my application, I have to display the bootsatarp grid for database entries. Since the number of entries is large enough to be viewed without having to fully scroll through the page, I wrap my table with a pre-scrollable div bootstrap, and this has enabled me to scroll through the table. However, all the time, the DIV is half the browser window. I tried almost everything and the suggestions, and they just do not work for me. I also tried to fix this with a java script, and it also failed.

This is my HTML code.

<div class="col-md-9">
<div  class="pre-scrollable">
<table class="table table-bordered table-hover header-fixed"  id="sometable">
                    <thead>
                  <tr>
                    <th>EMP_No</th>
                    <th>Name</th>
                    <th>Designation</th>
                    <th>Department</th>
                    <th>Type</th>
                    <th>#Days</th>
                    <th>Start Date</th>
                    <th>End Date</th>
                    <th>Half day</th>
                    <th>Status</th>
                  </tr>
                </thead>
                <tbody>
                </tbody>
                <?php  //php code for print the table
                 ?>
</div>      
</div>

I populate the table above with the results of the PHP code. I do not know how to set this DIV height to a fixed value or the full value of browser windows. Below are the CSS that use

<style>
table {
    font-family: arial, sans-serif;
    border-collapse: collapse;
    width: 100%;
}
td, th {
    border: 1px solid #dddddd;
    text-align: center;
    padding: 1px;
}
thead th {
    text-align: center;
    background-color: #3498db;
}
tr:nth-child(even) {
    background-color: #dddddd;
}
</style>

This is the results web page.

+4
3

max-height .pre- div bootstrap css.

.pre-scrollable {
    max-height: 340px;
    overflow-y: scroll;
}

.

+16

Twitter bootstrap - ... , div.

<style type="text/css">
        body, html {
            height: 100%;
            overflow: hidden;
        }

        .navbar-inner {
            height: 40px;
        }

        .scrollable {
            height: 100%;
            overflow: auto;
        }

        .max-height {
            height: 100%;
        }

        .no-overflow {
            overflow: hidden;
        }

        .pad40-top {
            padding-top: 40px;
        }
</style>
+3

css viewport. - :

<div class="pre-scrollable" style="max-height: 75vh">
     <table>...</table>
</div>

"75vh" 75% .

+2

Source: https://habr.com/ru/post/1652481/


All Articles