After converting Angular items into components, their heights in flex are no longer static

Currently, I am working on my portfolio in Angular and focusing on the skill page. I have a list of skills organized into categories, with each category displayed in its own box. The number of skills and progress for each category varies. Previously, the skill section was not a separate component, so if one box had fewer skills than another in the row, empty space would be added to ensure all elements in the row had the same height. However, now that I have converted the div into a component, the items(components) in the row have different heights based on their content.

Before:

<div class="flex-container">
   <div class="skill-section">
      <h3> Skill title</h3>
      <app-skill-progress></app-skill-progress>
      <app-skill-progress></app-skill-progress>
      <app-skill-progress></app-skill-progress>
   </div>
   <div class="skill-section">
      <h3> Skill title</h3>
      <app-skill-progress></app-skill-progress>
      <app-skill-progress></app-skill-progress>
   </div>
</div>

After:

<div class="flex-container">
   <app-skill-section></app-skill-section> // has 3 skills inside
   <app-skill-section></app-skill-section> // has 2 skills inside
</div>

Below are the styles for the classes:

.flex-container {
  display: flex;
  flex-wrap: wrap;
}

.skill-section {
  width: 560px;
  margin-bottom: 35px;
  margin-right: 30px;
  border-radius: 8px;
  padding: 24px 16px;
  background-color: #fff;
  box-shadow: 0px 5px 20px -1px rgba(0, 0, 0, 0.55);
  position: relative;
}

Answer №1

The .skill-section class has been moved inside the new component element, no longer a direct child of .flex-container. It is suggested to update the selector from .skill-section to app-skill-section and include display: block.

Here is how it should look:

.flex-container {
  display: flex;
  flex-wrap: wrap;
}
app-skill-section {
  width: 560px;
  margin-bottom: 35px;
  margin-right: 30px;
  border-radius: 8px;
  padding: 24px 16px;
  background-color: #fff;
  box-shadow: 0px 5px 20px -1px rgba(0, 0, 0, 0.55);
  position: relative;
  display: block;
}

Another option is to apply these styles directly to the :host element within the CSS for the new component:

:host {
  width: 560px;
  margin-bottom: 35px;
  margin-right: 30px;
  border-radius: 8px;
  padding: 24px 16px;
  background-color: #fff;
  box-shadow: 0px 5px 20px -1px rgba(0, 0, 0, 0.55);
  position: relative;
  display: block;
}

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

Implementing ngClass change on click within an Angular component using Jasmine: A comprehensive guide

It seems like the click event is not triggering and the ngClass is not changing to active on the button I am attempting to click. -- HTML: <div class='btn-group' role='group' aria-label=""> <button type='button&apos ...

Tailwind configuration is failing to export complete CSS styles

I have been attempting to integrate the entire Tailwind 3.0 CSS library into a new Laravel 8.* project in order to utilize the corePlugins feature to eliminate unwanted styles. Despite setting everything up quickly, I am only seeing the basic styles publis ...

expanding the close window icon beyond the boundaries of the modal container

I seem to be experiencing a CSS mistake that I can't figure out. The close window icon in my modal window is getting cut off at the edge and not displaying properly. Check out this JSFiddle link <div id="sendMsgForm" class="modal"> <div ...

Eliminate unnecessary space from a Bootstrap 4 Card

Using the Card class from Bootstrap 4, I'm struggling with an extra space on the right side: https://i.sstatic.net/5qb8y.png (Please ignore the 'porno' thing, haha). You can clearly see the extra space on the right. I've been attemp ...

Styling the first child element within a list using the li tag

<ul> <li class="bla">aaa</li> <li class="my_li">sss</li> <li class="my_li">ddd</li> <li class="my_li">fff</li> </ul> css: .my_li:first-child{ ...

Building custom components in Ionic 4

What is the best way to integrate a newly created component in Ionic 4 after executing ionic g component myComponent? I am looking to incorporate this custom component into my home page. ...

Unable to locate youtube.ts file in the Angular 2 project for the YoutubeAPI integration

I've been using a youtube.d.ts file from the DefinitelyTyped project. It functions perfectly in my WebStorm while I'm editing, but once I try to run it, I encounter a 404 error stating that typings/youtube.js is not found. This file doesn't ...

Overlap of images on a responsive CSS page

I'm venturing into the world of responsive design for the first time, but I seem to be facing some challenges. In the initial screenshot, you can see that the tower image is overlapping a div and I can't figure out where I went wrong. Check out t ...

The styling appears to be displaying differently on the website compared to how it looks on Bootply

Hey there! I recently created some pages on Bootply.com and attempted to transfer them to the website I'm building in Visual Studios. However, the styling ends up looking off and doesn't match how it appears on Bootply.com. Check out these pictur ...

Changing the value of a variable in RxJS filter operator when a certain condition is satisfied

I am facing an issue with my code where the setDischarges method is not being executed if the condition in the filter (!!discharges && !!discharges.length) is met. loading: boolean; this.discharge$ = this.dischargeService.getObservable('discharges&ap ...

List items are not appearing correctly on display

When attempting to design a basic navbar, I encountered an issue where the list items were stacking on top of each other instead of displaying horizontally as intended. The parent container has a position of relative, while the child is set to absolute. ...

Unable to establish the relative placement of Div elements

Currently, I am working on an Analog clock project using React, Typescript, and SCSS. My main goal is to keep the CSS code primarily in the SCSS file and minimize its use in inline HTML (or eliminate it completely). Here is an excerpt from my SCSS file: ...

Having trouble deploying an Angular Universal app to an AWS S3 bucket with server-side rendering (SSR

Transitioning from an Angular9 application to make it SEO friendly required me to switch to Angular Universal SSR. I followed the steps below: Ran the command: ng add @nguniversal/express-engine Ran the command: npm run dev:ssr Ran the command: npm run bu ...

Guide on integrating an Excel file into the ag-grid-angular platform

I was looking for the import method, but I couldn't seem to find it. Does anyone have any idea where it is located? Please inform me! ...

Eliminate unnecessary HTML elements in Angular

I am currently using ngSwitchCase for 3 different cases, and I have noticed that I am duplicating the same code inside each case. Is there a way to eliminate this redundancy? The redundant code is located within the "app-device" component <div *ngS ...

What is the reason behind the term "interpolation" for the double curly braces in Angular/

Even after over a year of experience with Angular/JS, I find myself struggling to truly grasp the concept of interpolation (for example, {{1+4}}). Can you explain the origin of this term in the context of Angular/JS and if it shares any similarities with ...

Executing asynchronous function in Angular using Typescript

My team and I are new to Angular and we are facing a challenge with invoking methods in sequence and returning a value. The issue is that the return statement is being executed before the completion of the execution process. We have tried various approac ...

I am attempting to extract data from the website by utilizing the correct CSS selectors, however, I continue to receive results suggesting that the element is not present

Struggling to create a bot for my own services, but encountering crashes when trying to run it. login_button = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "//div[@class='loginRegisterButtons sb- ...

Experiencing code coverage challenges in Angular 8 relating to function properties

https://i.sstatic.net/WQpVB.png Looking for suggestions on how to create a unit test case in Jasmine to address the code coverage problem. Any ideas? ...

Button placement that feels out of place

I'm looking to style an input-group with a form input and submit button using Bootstrap 5. Here's my current code: .card { margin: auto; width: 50%; padding: 10px; opacity: 0.9!important; top: 250px; } <div class="card-header"> ...