繁体   English   中英

CSS 编辑在谷歌浏览器控制台中工作,但在样式表中不工作

[英]CSS editing working in google chrome console, but not working in stylesheet

我正在尝试在 Ionic 4 中编辑表单。我可以在 chrome 中定位 HTML 元素,但是当我尝试在应用程序中的 CSS 中使用这些编辑时,它不起作用。

当我使用 chrome 向 Element 添加样式时,它的工作方式如下所示。

在此处输入图像描述

在此处输入图像描述

我试图在样式表中添加这些属性,例如

ion-item.div.item-native {
    background-color: blue !important;
}

div.item-native {
    background-color: blue !important;
}

.item-native {
    background-color: blue !important;
}

但结果就是这样,这不是我想要的。 在此处输入图像描述

为什么 CSS 不工作?

这是形式的 HTML

<form class="form" [formGroup]="validations_form" (ngSubmit)="tryRegister(validations_form.value)">
<ion-item id ="item-native">
      <ion-label id ="item-native" position="floating" color="primary">Email</ion-label>
      <ion-input id ="item-native" type="text" formControlName="email"></ion-input>
    </ion-item >
    <div class="validation-errors">
      <ng-container *ngFor="let validation of validation_messages.email">
        <div class="error-message" *ngIf="validations_form.get('email').hasError(validation.type) && (validations_form.get('email').dirty || validations_form.get('email').touched)">
          {{ validation.message }}
        </div>
      </ng-container>
    </div>
    <ion-item>
      <ion-label position="floating" color="primary">Password</ion-label>
      <ion-input type="password" formControlName="password"></ion-input>
    </ion-item>
    <div class="validation-errors">
      <ng-container *ngFor="let validation of validation_messages.password">
        <div class="error-message" *ngIf="validations_form.get('password').hasError(validation.type) && (validations_form.get('password').dirty || validations_form.get('password').touched)">
          {{ validation.message }}
        </div>
      </ng-container>
    </div>
    <ion-button class="submit-btn" expand="block" type="submit" [disabled]="!validations_form.valid">Register</ion-button>
    <label class="error-message">{{errorMessage}}</label>
    <label class="success-message">{{successMessage}}</label>
  </form>

删除 div 元素的点并停止正在运行的代码并重新启动它将工作......!!

错误 CSS

ion-item.div.item-native {
    background-color: blue !important;
}

右 CSS

ion-item div.item-native {
    background-color: blue !important;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM