修复列表中绝对定位div标签的高度

时间:2016-05-14 01:29:20

标签: javascript jquery html css css3

我在网格列表中放置了一个具有绝对位置的div标签,因此它被其他人包裹在那里。我想创建一个类,使绝对定位div的高度流动,直到将遇到另一个类来修复(或关闭)绝对定位div标签的高度!

或者找到一个解决方案,从ex:第1行到第3行给出绝对定位div的高度,依此类推?这是代码:

jsFiddle

<div id="wrap_day_kalendar">
    <div id="day_kalendar" class="ui-selectable">
        <div class="row"><span>Saturday, 14 May 2016</span></div>
        <div class="row dimgrey"><span>CEST +02:00</span></div>     

        <div class="row border-up">
            <div class="col-1 dimgrey text-right"><span class="">10 PM</span></div>
            <div class="col-11 cornsilk selectable ui-selectee"><span>&nbsp;</span></div>
        </div>
        <div class="row">
            <div class="col-1 dimgrey fix-border">&nbsp;</div>
            <div class="col-11 border-up-dashed cornsilk selectable ui-selectee">
                <span>&nbsp;</span>
                <span class="newevent">New event</span>
                <span class="newevent">Second event</span>

            </div>
        </div>  
        <div class="row border-up">
            <div class="col-1 dimgrey text-right"><span class="">9 PM</span></div>
            <div class="col-11 cornsilk selectable ui-selectee"><span>&nbsp;</span></div>
        </div>
        <div class="row">
            <div class="col-1 dimgrey fix-border">&nbsp;</div>
            <div class="col-11 border-up-dashed cornsilk selectable ui-selectee"><span>&nbsp;</span></div>
        </div>  
    <div class="row border-up">
        <div class="col-1 dimgrey text-right"><span class="">7 PM</span></div>
        <div class="col-11 cornsilk selectable ui-selectee"><span>&nbsp;</span></div>
    </div>
    <div class="row">
        <div class="col-1 dimgrey fix-border">&nbsp;</div>
        <div class="col-11 border-up-dashed cornsilk selectable ui-selectee"><span>&nbsp;</span></div>
    </div>  
    </div>
</div>

1 个答案:

答案 0 :(得分:2)

使用javascript / jQuery,您可以获得父div和x后续div的高度(如果您在这种情况下使用.col-11遍历div),那么您可以设置div的高度。

如果您想要将所有.newevent div设为当前单元格高度的3倍,这是一个(愚蠢的)示例:

UICollectionView