Vertical scroll table body inside bootstrap modal

我是研究僧i 提交于 2021-01-29 05:51:07

问题


I'm using bootstrap3 modal and trying to create a table inside a modal. I want the tbody to have vertical scroll. I've tried adding the height and overflow-y: auto to tbody, but it won't work.

I was able to have the entire modal scrollable, but I just want only the table body to be scrollable

Can anyone please help me?


回答1:


I've finally found an answer for this.

I adapted the code from here: http://jsfiddle.net/T9Bhm/7/

The CSS Solution:

    table {
        width: 100%;
    }

    thead, tbody, tr, td, th { display: block; }

    tr:after {
        content: ' ';
        display: block;
        visibility: hidden;
        clear: both;
    }

    thead th {
        height: 30px;

        /*text-align: left;*/
    }

    tbody {
        height: 120px;
        overflow-y: auto;
    }

    thead {
        /* fallback */
    }


    tbody td, thead th {
        width: 19.2%;
        float: left;
    }


来源:https://stackoverflow.com/questions/28187913/vertical-scroll-table-body-inside-bootstrap-modal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!