html - AngularJS 从 ng-repeat 设置父级高度

标签 html css angularjs

我有一个高度可变的 ng-repeat。 如果我使用固定高度,一切看起来都不错。但是我需要父面板的高度根据ng-repeat子元素自动调整,否则会出现溢出问题。

有什么办法吗?

固定高度(见底部溢出):

Overflow problems

没有固定高度:

enter image description here

面板代码:

<div class="my-panel" ng-repeat="x in month.days">
    <div class="panel-today" ng-show="x.today">
        TODAY
    </div>
    <div class="panel" ng-class="x.panel_class">
        <div class="panel-heading {{x.weekend}}">{{x.day}} {{x.date | date : 'dd-MM'}}</div>
        <div class="panel-body my-panel-body">
            <div ng-show="x.suspension != ''" style="width: 100%; text-align: center">
                <b>{{x.suspension}}</b>
            </div>
            <div ng-show="x.suspension == ''">
                <div class="well well-sm day-well">
                    <div class="day_period">
                        <div class="pull-right">
                            {{x.times.day.from}}<br/>
                            {{x.times.day.to}}
                        </div>
                        <div class="day_head">DAY</div>
                    </div>
                    <div ng-repeat="grade in x.staff.day.m">
                        <div  class="letterCircleM">
                            {{grade.code}}
                        </div> S SIPHO
                    </div>
                    <div ng-repeat="grade in x.staff.day.f" class="letterCircleF">
                        {{grade.code}}
                    </div>
                </div>
                <div class="well well-sm day-well">
                    <div class="day_period">
                        <div class="pull-right">
                            {{x.times.night.from}}<br/>
                            {{x.times.night.to}}
                        </div>
                        <div class="day_head">NIGHT</div>
                    </div>
                    <div ng-repeat="grade in x.staff.night.m">
                        <div  class="letterCircleM">
                            {{grade.code}}
                        </div> S SIPHO
                    </div>
                        <div ng-repeat="grade in x.staff.night.f" class="letterCircleF">
                        {{grade.code}}
                    </div>
                </div>
            </div>
        </div>
        <div class="panel-footer">
            <div class="panel-suspend" ng-show="x.suspension != ''">
                SUSPENDED
            </div>
            <div ng-show="x.suspension == ''">
                {{x.contract}}
            </div>
        </div>
    </div>
</div>

最佳答案

如果固定高度适合您,为什么不根据您在 ng-repeat 中通过 ng-style 重复的数据长度将其添加到父级?

ng-style="{ 'height': 30 * RepeatData.length + 'px' }

30 是一个“重复” block 的高度

关于html - AngularJS 从 ng-repeat 设置父级高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43495006/

相关文章:

JavaScript。图像翻转

javascript - 在 Angular JS 中动态应用 CSS 样式属性

angularjs - 如何在 angularjs 中使用 ngFor

javascript - 加载js文件时出现404错误

html - 如何在 HTML 页面中添加并正确格式化代码片段?

html - CSS 居中选项卡

javascript - 按字母顺序对 JSON 响应对象进行排序

css - 显示居中的图像行

javascript - 我的网站在移动版 chrome 中右侧显示空白,但在桌面版 chrome 中不显示

html - 仅在 Safari 中使用 flexbox 设置父 div 样式时,包含 span 的相邻 div 重叠