Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
How to make angular child component stretch css grid column defined in parent component

I have defined the styles of an angular parent component using css grid and want the child component to stretch across the 5 columns. Though other styles are getting applied on the the child component but the child component is not stretching from column 4 till column 99(defined in css file).

Here is the code for parent component

.parent-comp {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
}

::ng-deep .child-comp {
  grid-column-start: 4;
  grid-column-end: 9;
  background: red;
}
<div class="parent-comp">
  <app-child></app-child>
</div>

Child component

<p class="child-comp">
  child works!
</p>

My understanding is child component should start from column 4 of parent and end at starting line of column 9. But this is not working as my understand. Please help me to understand my mistake and how can I make it work

Screenshot of child component occupying only first grid

Stackblitz

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

If you look at the HTML in the browser dev tools you will see that angular inserts a host element for the child component called <app-child>.

The HTML will look something like...

<div class="parent-comp">
  <app-child>
    <p class="child-comp">child works!</p>
  </app-child>
</div>

You need to target the app-child element in your css selector in your parent component's css file...

::ng-deep app-child {
  grid-column-start: 4;
  grid-column-end: 9;
}

https://stackblitz.com/edit/angular-ivy-enagwe?file=src%2Fapp%2Fapp.component.css

about 4 years ago · Juan Pablo Isaza Report

0

And what about this?:

  <app-child class="child-comp"></app-child>

It works for you?

https://stackblitz.com/edit/angular-ivy-avijo8?file=src%2Fapp%2Fapp.component.html

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!