Setting the height of a parent element in AngularJS when using ng-repeat

I'm dealing with a ng-repeat that has varying heights. When I set a fixed height, everything looks fine. However, I need the parent panel's height to adjust automatically based on the ng-repeat child elements to avoid overflow issues.

Is there a way to achieve this?

Display with Fixed height (overflow at the bottom):

https://i.sstatic.net/x003C.png

Without a Fixed Height:

https://i.sstatic.net/nHjFC.png

The code for the panels:

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

Answer №1

Have you considered setting a fixed height that is determined by the length of the data being repeated in your ng-repeat loop? You can achieve this by using ng-style on the parent element.

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

Here, 30 represents the height of each block being repeated.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to ensure that the vertical scrollbar remains visible within the viewport even when the horizontal content is overflowing?

On my webpage, I have multiple lists with separate headers at the top. The number of lists is dynamic and can overflow horizontally. When scrolling horizontally (X-scrolling), the entire page moves. However, when scrolling vertically within the lists, I wa ...

The challenge of resizing images using Chrome Print CSS

I have a unique method for centering an oversized image within its container. Everything works flawlessly, except when attempting to print in Chrome (printing in FF and IE behaves as expected). In Chrome's print preview, the image does not resize at a ...

Learn how to apply formatting to all textboxes on an ASP.NET website using CSS without having to set the CSS class property for each individual textbox

I am currently developing a website using Asp.Net. I am looking for a way to customize the font, color, and background color of all the textboxes on my site using CSS. However, I would like to avoid having to assign a "cssclass" property to each individua ...

Transform the color of Max Mega Menu items on hover with another item in WordPress

Seeking help to change the color of my megamenu item when hovering over other items in the menu. Take a look at this image for reference: I've tried using these CSS styles but it didn't work as expected. #mega-menu-wrap-primary-menu #mega-menu-p ...

Using HTML, CSS, and jQuery to add a power sign to an input text box

Is there a way to enter square root and squared symbols into an input box using a calculator with buttons? When clicking a button, the value will be shown in the input box. For example, expressions like x²+x³ or 2√13 + 3√4. I'm primarily concern ...

Passing resolved data from a parent state to a nested view in Angular UI Router

Currently, I am developing an Angular web application that will showcase various financial events for the user. These events are categorized under a single ID and grouped into different categories. Each group needs to have its own HTML <table> for di ...

Accordion nested within another accordion

I am facing a challenge while trying to nest an accordion within another accordion. The issue is that the nested accordion only expands as much as the first accordion, requiring additional space to display its content properly. Any assistance with resolvin ...

Incorporating an HTML/Javascript game into a reactJS website: A step-by-step

After developing a game using plain javascript and HTML along with a few JS libraries, I find myself inquiring about the process of integrating this game into my ReactJS website. Typically, the game is initiated by opening the index.html file located with ...

Columns in Bootstrap compressed

Seeking advice regarding setting up a recruitment portal for my employer. Having trouble with the bootstrap scaffolding - columns appear squashed on smaller devices despite using xs columns. Looking for guidance to make it more responsive. Would greatly a ...

Are there any other methods of using HREF in an <asp:Button> besides OnClientClick for invoking an inline div?

I decided to create a concealed <div> on the same page and tried calling it with href="#", which worked perfectly. However, when I attempted to use the same code in ASP.net, I encountered some issues with Javascript or other factors that prevented it ...

Creating Interactive Graphs with HTML and JavaScript: A Guide to Dynamic Graph Drawing

I am seeking to create a dynamic graph using standard HTML, JavaScript, and jQuery (excluding HTML5). The nodes will be represented by divs with specific contents, connected by lines such as horizontal and vertical. The ability to add and remove nodes dyn ...

Creating a button in HTML that deletes code from a program: a step-by-step guide

Let me illustrate what I'm endeavoring to achieve. Below is the actual code: var info = { labels: ["March", "April"], datasets: [ { label: "Primary Info", fillColor: "rgba(220,220,220,0.2)", strokeColor: "rgba(220,220,220 ...

Switching from HTML to PHP programming

Trying to build a website from scratch and incorporate a form has been challenging. My goal is for the Submit button to send an email without launching any email program, but I'm facing redirection issues. Despite searching on Google for solutions, I ...

Text overlay on image sliders inside div containers

Is there a way to display div elements on top of an image slider, rather than behind it? I've tried using z-index and position: absolute with no success. Here is an example: HTML: <div id="header"> <img src="assets/images/header1.png" / ...

Failure of Styling Inheritance in Angular 2 Child Components from Parent Components

My Parent Component utilizes a Child Component. I have defined the necessary styles in the Parent CSS file, and these styles change appropriately when hovering over the div. However, the Child Component does not inherit the styling classes of the Parent Co ...

Incorporating filters within ui-sref for enhanced functionality

After coming across this answer, I realized it doesn't address my specific issue. My goal is to have the complete state name generated by my filter, rather than just using the filter for state parameters. Is there a way to use a filter to generate th ...

Encountering an error while attempting to launch an AngularJS application on Node.js? Let's

Currently, I am in the process of learning Angular. Whenever I attempt to run my code, an error message pops up: > <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1f7a737a7c6b6d70715f2b312f3115">[email protected]< ...

Angular's observable data fail to show on the screen

I am facing an issue with passing the data of an Observable fetched via an API request to a component variable for display. I have been trying but unable to make it work successfully. Any assistance would be greatly appreciated. Here is my code. Thank you. ...

Tips for embedding a file within a text box in HTML and enabling users to make direct edits

I am currently working on a feature that allows users to open a .txt or .html file from their file explorer and paste the contents into a textarea for editing and saving purposes. My question is whether it's possible to read the file content and auto ...

Steps for adding a background image to a div element

I am struggling to place my background behind the jumbotron div, but no matter what I do, it always ends up appearing below the image instead of on top of it. Can someone please guide me on how to resolve this issue? Note: I have a specific requirement wh ...