1

这是一个显示问题的 jsfiddle:http: //jsfiddle.net/FQxYB/9/

为了避免发布错误“不要只链接到小提琴”......这是小提琴的详细信息(为什么不能通过stackoverflow自动完成?)。

小提琴HTML:

<div class="gridster">
  <ul>
    <li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
        <div class='portlet'>
            <span>Something small that fits</span>
        </div>
    </li>
    <li data-row="2" data-col="1" data-sizex="1" data-sizey="1">
        <div>
            <span>Something like a header</span>
        </div>
        <div class='portlet'>
            <table>
                <tr>
                    <td>r1 c1</td>
                    <td>r1 c2</td>
                </tr>
                <tr>
                    <td>r2 c1</td>
                    <td>r2 c2</td>
                </tr>
                <tr>
                    <td>r3 c1</td>
                    <td>r3 c2</td>
                </tr>
                <tr>
                    <td>r4 c1</td>
                    <td>r4 c2</td>
                </tr>
                <tr>
                    <td>r5 c1</td>
                    <td>r5 c2</td>
                </tr>
                <tr>
                    <td>r6 c1</td>
                    <td>r6 c2</td>
                </tr>
                <tr>
                    <td>r7 c1</td>
                    <td>r7 c2</td>
                </tr>
                <tr>
                    <td>r8 c1</td>
                    <td>r8 c2</td>
                </tr>
                <tr>
                    <td>r9 c1</td>
                    <td>r9 c2</td>
                </tr>
                <tr>
                    <td>r10 c1</td>
                    <td>r10 c2</td>
                </tr>
            </table>
        </div>
    </li>
  </ul>

小提琴代码:

$(function(){
    $(".gridster ul").gridster({
        widget_margins: [15, 15],
        widget_base_dimensions: [100, 100]
    });
});

小提琴CSS:

.portlet
{
    height: 100%;
    width: 100%;
    overflow: auto;
}

.gridster {
    position:relative;
    background-color: gray;
} 

li {
    background-color: white;
    width: 150px;
    height: 150px;
    border: solid 2px black;
}

.gridster > * {
    margin: 0 auto;
    -webkit-transition: height .4s;
    -moz-transition: height .4s;
    -o-transition: height .4s;
    -ms-transition: height .4s;
    transition: height .4s;
}

.gridster .gs_w{
    z-index: 2;
    position: absolute;
}

.ready .gs_w:not(.preview-holder) {
    -webkit-transition: opacity .3s, left .3s, top .3s;
    -moz-transition: opacity .3s, left .3s, top .3s;
    -o-transition: opacity .3s, left .3s, top .3s;
    transition: opacity .3s, left .3s, top .3s;
}

.ready .gs_w:not(.preview-holder) {
    -webkit-transition: opacity .3s, left .3s, top .3s, width .3s, height .3s;
    -moz-transition: opacity .3s, left .3s, top .3s, width .3s, height .3s;
    -o-transition: opacity .3s, left .3s, top .3s, width .3s, height .3s;
    transition: opacity .3s, left .3s, top .3s, width .3s, height .3s;
}

.gridster .preview-holder {
    z-index: 1;
    position: absolute;
    background-color: #fff;
    border-color: #fff;
    opacity: 0.3;
}

.gridster .player-revert {
    z-index: 10!important;
    -webkit-transition: left .3s, top .3s!important;
    -moz-transition: left .3s, top .3s!important;
    -o-transition: left .3s, top .3s!important;
    transition:  left .3s, top .3s!important;
}

.gridster .dragging {
    z-index: 10!important;
    -webkit-transition: all 0s !important;
    -moz-transition: all 0s !important;
    -o-transition: all 0s !important;
    transition: all 0s !important;
}

/* Uncomment this if you set helper : "clone" in draggable options */
/*.gridster .player {
  opacity:0;
}*/

小提琴资源: http: //gridster.net/dist/jquery.gridster.js

对于第二个正方形(下一个),我需要底部 div 不超过 LI 的范围。

粗略地说,“标题”div 的内容可以是任意大小(标题内容因上下文而异)。但是“body” div 的内容需要在必要时显示滚动条并保持在 LI 的范围内。

我“迷失如海”。我尝试了许多不同的方案......但没有一个甚至接近(主要是使用包装 div 和显示的变体:table/table-row/table-cell)。

非常感谢您的帮助!

4

1 回答 1

3

元素的溢出属性li需要设置为overflow:hiddenoverflow:auto否则元素将默认为overflow:visible. 在这里看小提琴

于 2013-02-07T01:49:04.047 回答