Angular 2-CSS background-color不起作用

tra*_*ada 3 html css angular

我在使用Angular 2定义主体的背景颜色时遇到问题。我尝试过更改html,主体,容器流体的颜色,但它没有改变。我还更改了app.component.css中的html和body,但是没有用。

我其余的CSS都还可以,所以浏览器得到了样式表

app.component.html:

<jogo></jogo>
Run Code Online (Sandbox Code Playgroud)

app.component.css:

html, body{
    background-color: pink;
}
Run Code Online (Sandbox Code Playgroud)

jogo.component

<div class="container-fluid" *ngIf="showPlay">
    <div class="row">      
     <div class="col-xs-8 col-md-8 col-lg-8c">
            <p align="center">
                Qual é<br/>a<br/>Música?
        </p>
     </div>
    </div>
  <div class="row">
    <div class="col-xs-4 col-md-4 col-lg-4"></div>
        <div align="center">
            <button type="button" class="rounded-circle">Play</button>
        </div>
  </div>    
</div> 
<div class="container-fluid" *ngIf="showJogo">
  <div class="row">
   <div class="col-xs-3 col-md-3 col-lg-3" id="tocador">
        Segunda
        <audio controls>
            <!-- caminho devera ser trocado pelo do firebase? -->
            <source src="/assets/Queen - Love of My Life.mp3" type="audio/mpeg">
            Your browser does not support the audio element.
        </audio>
   </div>
</div>
<div class="row">
    <div class="col-xs-3 col-md-3 col-lg-3" id="pontos">Pontos</div>
</div>
<div class="row">
    <div class="col-xs-3 col-md-3 col-lg-3" id="tempo">Tempo</div>
</div>
<div class="row">
   <div class="col-xs-3 col-md-3 col-lg-3" id="pergunta">Pergunta</div>
</div>  
</div>
Run Code Online (Sandbox Code Playgroud)

jogo.component.css:

body{
    background-color: pink;
}
p {
    font-family: 'Lobster', cursive;
    font-size: 3.0em;
    color: #990000;
    /* Rotate div */
    -ms-transform: rotate(7deg); /* IE 9 */
    -webkit-transform: rotate(7deg); /* Safari 3-8 */
    transform: rotate(-12deg);

}
button {
    background-color: #990000;
    color: #F0D1B7;
    font-size: 1.5em;
    border: none;
    border-radius: 35px;
    width: 10%;
}
Run Code Online (Sandbox Code Playgroud)

未在身体标签处应用CSS: 身体标记未应用CSS

加载的样式表: 在此处输入图片说明

Aja*_*jay 8

Angular创建Shadow Dom,以将样式应用于不同的组件。

要将样式应用于根元素,我们可以在根文件夹中使用style.css。

style.css

html, body{
    background-color: pink;
}
Run Code Online (Sandbox Code Playgroud)