Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

129
Visualizações
Styling Angular 2 component tag

Inside my app-root component, I've app-container component. How would I style the app-container component?

HTML:

<app-container></app-container>

CSS:

app-container {
  background: red;
}

^ The above css doesn't work.

I want to style and position the app-container component. I tried googling but couldn't find a proper solution. Please Help.

Thanks in advance!

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Yes there is. If you have enabled shadow-dom or the emulation of shadow-dom you can style the tag via the :host property. (Emulation is enabled per default)

E.G.

:host{
   background-color:red;
}

I highly suggest you this article: https://angular.io/guide/component-styles

Your css code above should work if it is in the global css file not in the component css file.

Don't forget to check the styleUrl path. Here an example of styleUrls.

@Component({
  selector: 'hero-details',
  template: `
    <h2>{{hero.name}}</h2>
    <hero-team [hero]=hero></hero-team>
    <ng-content></ng-content>
  `,
  styleUrls: ['app/hero-details.component.css']
})
export class HeroDetailsComponent {
/* . . . */
}

Here more details on emulated / native -shadow dom: https://angular.io/guide/component-styles#view-encapsulation

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda