Reputation: 589
I want to stretch the child component. Why does this not work?
<app-tmp></app-tmp>
is a component that I want to stretch but does not stretch, while the same code is not wrapped in component stretches.
<div style="width: 100%; display: flex; justify-content: stretch; flex-wrap: wrap; background-color: yellow">
<p style="height: 50px; width: 100%; background-color: skyblue">This streches</p>
<app-tmp></app-tmp>
</div>
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-tmp',
template: `
<p style="height: 50px; width: 100%; background-color: skyblue">
This does not stretch
</p>
`,
styleUrls: ['./tmp.component.scss']
})
export class TmpComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
justify-content: flex-end, etc works, but only justify-content: stretch does not work.
Upvotes: 2
Views: 626
Reputation: 369
Angular components generate a stylesheet for styling of component.
So put the styles in the stylesheet here it is tmp.component.scss
:host {
height: 50px;
width: 100%;
background-color: skyblue
}
This is somewhat similar to @N.F. answer
Upvotes: 2