Вопрос

I have a resizable and movable div using JQuery UI. I want a table inside it that scrolls vertically. Trying to set the table height to 100% basically does nothing, and absolute positioning with top and bottom of 0 doesn't work either. I have tried to put a separate div as a container and that has gotten me closer than anything, but it still does not behave properly.

Here is the fiddle: http://jsfiddle.net/scottbeeson/KrP7v/1/

Here is the relevant CSS:

table {
    border-collapse: collapse;
    width: 100%; height: 100%;
}
#tableContainer {
    height: 100%; width: 100%;
    overflow-x: hidden;
    overflow-y: scroll;
}

And the basic HTML layout:

<div id="window">
    <div id="header">Draggable Header</div>
    <div id="tableContainer">
    <table>
        <thead>
            <tr>
                <td>Column 1</td>
                <td>Column 2</td>
            </tr>
        </thead>
        <tbody>
            ...
        </tbody>
    </table>
    </div>
</div>
Это было полезно?

Решение

I think that this is what you want.

http://jsfiddle.net/KrP7v/12/

#window {
    width: 500px;
    height: 400px;
    min-width: 100px;
    min-height: 100px;
    border-bottom: 1px solid gray;
}
#header {
    height: 25px;
    line-height: 25px;
    background-color: gray;
    color: white;
    text-align: center;
}
table {
    min-height: 300px;
    height: 100%;
    width: 100%;
    border-collapse: collapse;
}
#tableContainer {
    position: absolute;
    top: 25px;
    bottom: 0px;
    left: 0px;
    right: 0px;
    margin: 0;
    padding: 0;
    overflow: auto;
}
td {
    padding: 5px;
    margin: 0px;
    border: 1px solid gray;
}
tr:last-child td {
    border-bottom: none;
}

Другие советы

Here's what you can do:

http://jsfiddle.net/KrP7v/4/

#window {
  width: 400px; 
  border: 1px solid green;
  overflow-x: scroll;
  overflow-y: scroll;
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top