Giving height to table and row in Bootstrap

前端 未结 5 1910
说谎
说谎 2020-12-30 23:30

I am using Bootstrap 3 , i am trying to give height to table and row, but nothing is working for me .

I tried setting line-height

相关标签:
5条回答
  • 2020-12-30 23:50

    The simple solution that worked for me as below, wrap the table with a div and change the line-height, this line-height is taken as a ratio.

    <div class="col-md-6" style="line-height: 0.5">
                                    <table class="table table-striped" >
                                        <thead>
                                        <tr>
                                            <th>Parameter</th>
                                            <th>Recorded Value</th>
                                            <th>Individual Score</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr>
                                            <td>Respiratory Rate</td>
                                            <td>Doe</td>
                                            <td>john@example.com</td>
                                        </tr>
                                        <tr>
                                            <td>Respiratory Effort</td>
                                            <td>Moe</td>
                                            <td>mary@example.com</td>
                                        </tr>
                                        <tr>
                                            <td>Oxygon Saturation</td>
                                            <td>Dooley</td>
                                            <td>july@example.com</td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>

    Try changing the value as it fits for you.

    0 讨论(0)
  • 2020-12-30 23:51

    CSS:

    tr {
    width: 100%;
    display: inline-table;
    height:60px;                // <-- the rows height 
    }
    
    table{
     height:300px;              // <-- Select the height of the table
     display: -moz-groupbox;    // For firefox bad effect
    }
    tbody{
      overflow-y: scroll;      
      height: 200px;            //  <-- Select the height of the body
      width: 100%;
      position: absolute;
    }
    

    Bootply : http://www.bootply.com/AgI8LpDugl

    0 讨论(0)
  • 2020-12-30 23:52

    What worked for me was adding a div around the content. Originally i had this. Css applied to the td had no effect.

            <td>           
                 @Html.DisplayFor(modelItem => item.Message)           
            </td>
    

    Then I wrapped the content in a div and the css worked as expected

           <td>
                <div class="largeContent">
                    @Html.DisplayFor(modelItem => item.Message)
                </div>
            </td>
    
    0 讨论(0)
  • 2020-12-30 23:55

    http://jsfiddle.net/isherwood/gfgux

    html, body {
        height: 100%;
    }
    #table-row, #table-col, #table-wrapper {
        height: 80%;
    }
    
    <div id="content" class="container">
        <div id="table-row" class="row">
            <div id="table-col" class="col-md-7 col-xs-10 pull-left">
                <p>Hello</p>
                <div id="table-wrapper" class="table-responsive">
                    <table class="table table-bordered ">
    
    0 讨论(0)
  • 2020-12-31 00:01

    For the <tr>'s just set

    tr {
       line-height: 25px;
       min-height: 25px;
       height: 25px;
    }
    

    It works with bootstrap also. For the 100% height, 100% must be 100% of something. Therefore, you must define a fixed height for one of the containers, or the body. I guess you want the entire page to be 100%, so (example) :

    body {
        height: 700px;
    }
    .table100, .row, .container, .table-responsive, .table-bordered  {
        height: 100%;
    }
    

    A workaround not to set a static height is by forcing the height in code according to the viewport :

    $('body').height(document.documentElement.clientHeight);
    

    all the above in this fiddle -> http://jsfiddle.net/LZuJt/

    Note : I do not care that you have 25% height on #description, and 100% height on table. Guess it is just an example. And notice that clientHeight is not right since the documentElement is an iframe, but you'll get the picture in your own projekt :)

    0 讨论(0)
提交回复
热议问题