Using Angular to scroll within a <div> that is obstructed by other <div>s and concealed by

I am currently in the process of developing a website using Angular. I have implemented a card feature that allows for text selection from a menu on the left side. The texts are displayed using the *ngIf directive. However, I encountered an issue where if the first and lowest layer of text overflows and you try to scroll, it doesn't work because the other texts above it remain disabled by *ngIf.

Upon testing with only one layer of text, everything worked perfectly. Is there any way to ensure that the disabled texts controlled by *ngIf completely disappear so they do not obstruct scrolling on the lower layers?

Below is the HTML code snippet for the Card Component:

<div class="wrapper">
<div class="container">
    <div class="item1">{{headLine}}</div>
    <div class="item2">
        <ul class="partList">
            <a *ngFor="let i of array" (click)="onClickPart(i)" class="part{{i}}"><li>{{prefix}}{{i}}</li></a>
        </ul>
    </div>
    
    <div *ngFor="let i of array" class="item3">
         <p *ngIf="part == i">{{texts[i-1]}}</p>
    </div>
    <div class="item4"><img src="../../assets/Spartans2.jpg" alt=""></div>
</div>

Here is the relevant CSS code snippet which utilizes Grid Display to style the Card. Feel free to disregard the comments:

.container {
    display: grid;
    grid-template-columns: 70px 140px 140px 140px 140px 140px;
    grid-template-rows: 70px 120px 120px;
    border-radius: 71px;
}

.item1 {
    grid-column-start: 1;
    grid-column-end: 7;
    grid-row-start: 1;
    grid-row-end: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    border-top-left-radius: 71px;
    border-top-right-radius: 71px;
    border: 1px solid gray;
    border-bottom: none;
    font-weight: 700;
}

.item2 {
    grid-column-start: 1;
    grid-column-end: 2;
    grid-row-start: 2;
    grid-row-end: 4;
    border-bottom-left-radius: 71px;
    border: 1px solid gray;
    border-right: none;
}

.item3 {
    grid-column-start: 2;
    grid-column-end: 4;
    grid-row-start: 2;
    grid-row-end: 4;
    border: 1px solid gray;
    padding: 10px;
    overflow: auto;
}

.item4 {
    grid-column-start: 4;
    grid-column-end: 7;
    grid-row-start: 2;
    grid-row-end: 4;
    object-fit: conatain;
    border: 1px solid gray;
    border-left: none;
    border-bottom-right-radius: 71px;
}

.item4 img {
    max-width: 100%;
    max-height: 100%;
}

.partList {
    display: flex;
    flex-direction: column;
    align-items: center;
    list-style-type: none;
    gap: 15px;
}

.partList a {
    text-decoration: none;
    cursor: pointer;
}

.partList a:hover {
    opacity: 0.8;
}

.part1 {
    margin-top: 20px;
}

Answer №1

After trying a few different approaches, I finally found a solution. I decided to eliminate the *ngFor loop and *ngIf statement. Instead, I opted to update the text directly in the div. This way, we no longer have 4 overlapping divs, but rather one that dynamically changes its content. I can't help but wonder about the inner workings of *ngIf - does it simply hide elements or completely remove them from view?

<div class="wrapper"> <!--Remove -->
<div class="container">
    <div class="item1">{{headLine}}</div>
    <div class="item2">
        <ul class="partList">
            <a *ngFor="let i of array" (click)="onClickPart(i)" class="part{{i}}"><li>{{prefix}}{{i}}</li></a>
        </ul>
    </div>
    <div class="item3">
        {{currentText}}
    </div>
    <div class="item4"><img src="../../assets/Spartans2.jpg" alt=""></div>
</div>

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

Display a tooltip when the cursor hovers close to a line in D3 visualizations

Currently, I have a D3js line chart with SVG circles added to the points. When users hover over these circles, they can see a tooltip. https://i.sstatic.net/kYpeg.png https://jsfiddle.net/jhynag08/38/ However, I would like the tooltip to appear when user ...

Is there a way to switch on and off an ngrx action?

Here is a statement that triggers a load action to the store. The relevant effect will process the request and return the response items. However, my goal is to be able to control this action with a button. When I click on start, it should initiate dispa ...

Angular custom filter with FabricJS

I am working with a binary/grayscale image and my objective is to filter the image so that all white color becomes transparent and all dark colors change to a specific user-defined color. I am facing challenges in creating a custom filter in Angular. I ha ...

Navigating through an Angular 2 service

I'm struggling to retrieve an array from a JSON API and then loop through it. I can't seem to grasp how it all fits together. Any guidance would be greatly appreciated. This is what my service looks like: import {Injectable} from '@angular ...

What is the best way to incorporate a logo container and a horizontal divider into my top navigation bar using Bootstrap?

I'm currently working on designing a top navigation bar that features a logo with color #1 as the background on the left side. The logo is then separated by a grey horizontal divider, followed by color #2 representing the application name beside the d ...

Layering an object on top of a clone using CSS

I am working on a webpage with a jQuery menu located at the following link: Menu To accommodate more items and have greater control, I duplicated the menu twice. However, when hovering over them, the duplication is visible in the background. Is there a ...

Attempt the HTTP request again only for specific status codes

When developing my Angular application, I encountered a situation where I needed to make an HTTP call to a backend server. To enhance its reliability, I decided to incorporate an interceptor to implement the retry pattern. In the past, I utilized RxJS&apo ...

Uploading images using the power of Angular and Node.js

I have been struggling with a persistent issue for quite some time now, and I have not been able to find a solution anywhere. My goal is to allow users to update their avatars on their profiles. However, every time I attempt to pass the file to my node ser ...

Generate a new Angular component by only creating the TypeScript file

As a newcomer to Angular, I recently purchased the Metronic theme. After installing all necessary components, including the latest version of angular CLI, I encountered an issue. Whenever I run the command ng generate component test, it only creates a test ...

jQuery form experiencing a small problem

I need assistance with a form that has four fields. Specifically, I am looking for a solution where the visibility of the County field is dependent on the selection made in the Country field. When UK is chosen in the Country field, I want the County field ...

The CSS top border is failing to display

For a school project, I've been attempting to add a top border to a set of hyperlinks in order to separate them from the title. However, after spending over an hour on this task, I still can't seem to get it to work. Below is the CSS code for th ...

ColdFusion encounters an HTML form error, presenting the message: "There is an undefined element in the FORM."

I'm attempting to submit an HTML form that contains checkboxes for each day of the week. Whenever a checkbox is checked, I assign a value of 1 to it. To handle unchecked checkboxes, I set a default value of 0 using a CFPARAM tag in the form action pag ...

The unitPngFix plugin ensures that the display of hidden div elements cannot be altered

I have been trying to resolve an issue with PNG files and transparency in IE browsers on my website. I have made progress, but there seems to be a problem specifically with IE6. To display transparent PNG images correctly on my site in IE browsers, I am u ...

Is it recommended for the browser to download multiple images when utilizing srcset?

Here is my HTML markup: <img srcset="https://unique.cloudinary.com/xxx/image/upload/c_scale,w_300/v1653408278/notforsquares/ll/DSCF4429.jpg 300w, https://unique.cloudinary.com/makingthings/image/upload/c_scale,w_600/v1653408278/notforsquares/ll ...

Automatic Full-Screen Switching Upon Video Playback in HTML5

Currently, I have a video clip set to play when the timer reaches a certain point. My goal is for the video to automatically enter full-screen mode when it starts playing and return to its original position when it stops, as the timer will continue ticking ...

Press the "show additional content" button on the nytimes.com website using selenium

I'm experiencing difficulty scrolling through this webpage. Once I reach the bottom of the page, I am unable to locate and click on the "SHOW MORE" button using selenium. self.driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") ...

Incorporating RFID reader functionality into a website

I am currently facing an issue with integrating an RFID card reader into a web page. After some research, it seems that the solution involves creating an ActiveX component and using JavaScript. My question is, how can we go about building an ActiveX compo ...

Encountering an issue with npm installation on AWS Ubuntu

I need assistance with deploying my Angular 2 application on AWS Ubuntu. While I was able to successfully install npm on Ubuntu, I encountered an error when trying to build my application using "npm install". The error mentions something about "extract:typ ...

Tornadofx highlight selected row with CSS

I am attempting to modify the background color of a selected row and apply the same change to a listview. When I use cell{backgroundColor += Color.BLACK}, it successfully changes the color, but it does not retain the selection color as intended.I have al ...

Utilizing angularjs ng-repeat directive to present JSON data in an HTML table

I've been struggling to showcase the JSON data in my HTML table using AngularJS ng-repeat directive. Here's the code snippet: <thead> <tr> <th ng-repeat="(header, value) in gridheader">{{value}}</th> </tr> </ ...