Simple Solutions for Moving Containers Up in Angular When Clicked

In the left side container, I have a header and sub-header, while the right side container contains text. However, whenever I click on the sub-header to display text on the right side, both container positions shift upward, hiding the header text. I'm unsure of what is causing this issue, so any suggestions or help would be greatly appreciated.

HTML

        <div class="container-inside-dialog">
            <div class="row">
                <h1 class="primary-text header">Help Documentations</h1>
                <div class="column left">
                    <mat-nav-list>
                        <mat-expansion-panel class="exp-panel" *ngFor="let section of mappedSections">
                            <mat-expansion-panel-header style="align-items: center;">
                                <div>{{section.sectionName}}</div>
                            </mat-expansion-panel-header>
                            <div>

                                <a mat-list-item *ngFor="let subsection of section.subSections"
                                    (click)="navigateToSubsection(section.id,subsection.id)">{{subsection.sectionName}}
                                </a>

                            </div>
                        </mat-expansion-panel>
                    </mat-nav-list>
                </div>
                <div class="column right">
                     <div *ngFor="let section of mappedSections">
                        <h1>{{section.sectionName}}</h1>
                        <div *ngFor="let subsection of section.subSections">
                            <h2>{{subsection.sectionName}}</h2>
                            <p id="s{{section.id}}ss{{subsection.id}}" class="multi_lines_text"
                                [innerHTML]="subsection.text"></p>
                        </div>
                    </div>
                </div>
            </div>
        </div>

TS

  navigateToSubsection(sectionId, subsectionId) {
    document.querySelector(`#s${sectionId}ss${subsectionId}`).scrollIntoView({ behavior: 'smooth' })
  }

CSS

.dialog-container {
  width: 55vw;
  height: 65vh;
  overflow:hidden;
  overflow-y: hidden !important;
  padding: 2px;
  margin: 0 20px;
}

.container-inside-dialog {
  width: 100%;
  height: 100%;
  padding: 10px;
  overflow:hidden;
  overflow-y: hidden !important;
 }


* {
  box-sizing: border-box;
}

.column {
  float: left;
  padding: 10px;
}

.left {
  width: 38%;
  margin-top: 05px;
  position: relative;
  height: 530px;
  overflow-y: auto;
}

.right {
  position: relative;
  width: 62%;
  height: 530px;
  overflow-y: auto;
}

.button{
  width: 287px; 
  text-align: left; 
  padding-left: 25px; 
  height: 47px;
}

.edit-button{
  top: -50px; 
  left: 230px;
}

/* Clear floats after the columns */
.row:after {
  position: relative;
  content: "";
  display: table;
  clear: both;
}

Displayed are images showing the layout before and after clicking the subsection. Any insights or observations from the code above would be highly appreciated. Thank you.

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

https://i.sstatic.net/1Tag7.png

Answer №1

To fix any potential layout issues caused by padding or margin settings, you can try adding the following CSS code to your global stylesheet:

html, body { 
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}  

I hope this solution works for you. Happy coding!

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

Navigating the complexities of managing numerous checkboxes in React

I am a beginner with react and recently received a task to complete. The requirements are: Show multiple checkboxes. The order of checkbox names may change in the future, allowing the client to decide the display order. Display checkboxes based on their a ...

Saving the state of checkboxes in Angular Material

I am trying to figure out a solution for storing checkbox values, specifically whether they have been checked before or not. For example, I have this dialog: https://i.sstatic.net/c16Ju.jpg After clicking on a checkbox and then clicking Save, the checkbox ...

What is the solution to the strict mode issue in ANGULAR when it comes to declaring a variable without initializing it?

Hi everyone! I'm currently learning Angular and I've encountered an issue when trying to declare a new object type or a simple string variable. An error keeps appearing. this_is_variable:string; recipe : Recipe; The error messages are as follows ...

Tips for customizing the appearance of date circles and text in Vue V-Calendar.io

On v-calendar.io, there is a demo showcasing the correct display where the date "2018-01-01" has a red background and dark text: However, my display does not match that. I have included Vue.js and v-calendar through CDN, and the page is formatted in HTML ...

Simplify TypeScript code by converting null or undefined values to numbers

When working with a product, it's important to keep in mind that it can be undefined or null; furthermore, the price within the product can also be undefined or null. For example: getClasses(key: number): string { let product = this.mo ...

Making Angular2 Templates More Efficient with Array.prototype.filter()

I have a variable named networkInterface that includes an array called services. My objective is to create a checkbox input that indicates whether a specific service_id exists within the services array of the networkInterface. An illustration of JSON `int ...

Sending the :id parameter to the Service component

In the early days of my Angular journey, I have a simple question. Currently, I am utilizing the WordPress REST API to showcase a list of posts from a specific category by using posts?categories={ID HERE}. However, I am facing an issue in passing the ID f ...

I'm facing an issue with my LAMP stack where the image appears when I access it through a URL, but doesn't seem to load when I try to load it using jQuery

My PHP file is located at path/renderer/renderImage.php and it generates a PNG image that displays correctly in the browser when I visit the URL directly. However, when I try to load this image into a DIV using jQuery from path/index.html with the followin ...

updating the row of an html table with elements from a javascript object

I am faced with the task of dynamically adding rows to a table based on the number of elements in my JavaScript object. The object consists of keys and arrays of values. userobject={ ID: [1,2,3] IP_Address: ["12.21.12 ...

How can I ensure my variable in Angular 2 waits asynchronously for values to be assigned?

I encountered the following error: TypeError: Cannot read property 'length' of undefined at PaginationComponent.ngOnChanges (pagination.component.ts:38) This is how my PaginationComponent is set up: @Input() items = []; @Input('page-siz ...

Creating getter and setter functions for an input field model property in Angular

I need help creating getter and setter methods for an input field property. Here is my attempted code: import { Component } from '@angular/core'; @Component({ selector: 'my-app', templateUrl: './app.component.html', st ...

Tips for Adjusting the Size of a Search Bar

I've encountered an issue with a form I was developing. I decided to start fresh on an old project that included recreating the Google homepage design. While I aimed for an exact replica, some elements were unnecessary. The search box (form) moved to ...

Eliminate redundant choices in the selection dropdown

I utilized Angular 5 to implement a select dropdown that is dynamically populated with data fetched from a web server. My goal is to filter out items with duplicate values of the object property DocumentGroup without relying on a mix of jQuery and Angular ...

The Angular Material date picker unpredictably updates when a date is manually changed and the tab key is pressed

My component involves the use of the Angular material date picker. However, I have encountered a strange issue with it. When I select a date using the calendar control, everything works fine. But if I manually change the date and then press the tab button, ...

Angular reactive forms allow you to create dynamic forms with fields that change

Consider the following data structure: formAviso: FormGroup; deapartamentos: [ {nombre: 'Amazonas', codigo: 41}, {nombre: 'Ancash', codigo: 43}, {nombre: 'Apurimac', codigo: 83}, ... ] constructor() { this.formAvi ...

Encountering issues when passing a string as query parameters

How can I successfully pass a string value along with navigation from one component to another using query parameters? Component1: stringData = "Hello"; this.router.navigate(['component2'], { queryParams: stringData }); Component2: ...

Tips for speeding up your website by preloading versioned files in HTML

Tools like Google Lighthouse and PageSpeed recommend preloading important requests using <link rel=preload> to enhance website performance. When it comes to static files with unchanging filenames, the process is straightforward. However, how can I ...

Converting a string[] to an EventEmitter string[] in Angular 4 with TypeScript: Step-by-step guide

Programming Language: Typescript – written as .ts files Development Framework: Angular 4 I'm currently working on an application that is supposed to add chips (similar to tags in Angular 1) whenever a user types something into the input box and hi ...

Angular2 had a delay in processing the 'mouse wheel' input event for x milliseconds because the main thread was occupied

Currently, I am working with Angular2 (r.2.0.0) along with typescript (v.1.8.10). I have encountered an issue where Chrome does not respond while scrolling and displays a warning message stating: "Handling of 'mouse wheel' input event was delayed ...

Unable to change the alignment to the left in the CSS styling

My table has th elements with a text-align: left property. I tried to override this with text-align: center in my CSS, but it's not working. Can anyone suggest a reason why? Here is my table: <table class="days_table" align="center"> <thea ...