简体   繁体   English

固定列表中绝对位置的div标签的高度

[英]Fix height of an absolute positioned div tag in a list

I positioned a div tag with absolute position in a grids list, so it is wrapped there by others div's. 我在网格列表中放置了绝对位置的div标签,因此它被其他div包裹。 I would like to make a class that make the height of the absolute positioned div to flow till will meet another class to fix (or to close) the height of the absolute positioned div tag! 我想创建一个使绝对定位div的高度流动的类,直到遇到另一个要修复(或关闭)绝对定位div标签的高度的类!

Or to find a solution to give a height to absolute positioned div from ex: row 1 to row 3 and so on? 还是要找到一个解决方案来给绝对位置div(例如:第1行到第3行)的高度赋予一个高度,依此类推? here is the code: 这是代码:

jsFiddle 的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>

With javascript/jQuery you can get the height of the parent div and of the x subsequent divs (if you iterate through the divs with .col-11 in this case) then you set the height of your div. 使用javascript / jQuery,您可以获取父div的高度和x个后续div的高度(如果在这种情况下使用.col-11遍历div),则可以设置div的高度。

Here is a (stupid) example if you'd want to make all .newevent div 3 times the current cell height: 这是一个(愚蠢的)示例,如果您想将所有.newevent div设置为当前像元高度的3倍:

    $(document).ready(function () {
       $('.newevent').each(function() {
           var parentHeight = parseInt($(this).parent().css('height'));
           $(this).css('height', 3 * parentHeight  + 'px');
      });
   })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM