简体   繁体   English

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

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

I am trying to edit a form in Ionic 4. I can target HTML elements in chrome, however when I try to use these edits in the CSS within the app, it does not work.我正在尝试在 Ionic 4 中编辑表单。我可以在 chrome 中定位 HTML 元素,但是当我尝试在应用程序中的 CSS 中使用这些编辑时,它不起作用。

When I add a style to the Element using chrome, it works like shown below.当我使用 chrome 向 Element 添加样式时,它的工作方式如下所示。

在此处输入图像描述

在此处输入图像描述

I have tried to add these properties in the style sheet such as this我试图在样式表中添加这些属性,例如

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

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

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

but it the result is this, which is not what I want.但结果就是这样,这不是我想要的。 在此处输入图像描述

How come the CSS is not working?为什么 CSS 不工作?

this is the HTML of form这是形式的 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>

Remove dot for div element and Stop your running code and restart it will Work...!!删除 div 元素的点并停止正在运行的代码并重新启动它将工作......!!

Wrong CSS错误 CSS

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

Right CSS右 CSS

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

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

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