Html 如何更改NgPrime组件的样式?
我想取CSS值在Html 如何更改NgPrime组件的样式?,html,angular,typescript,primeng,Html,Angular,Typescript,Primeng,我想取CSS值在.myclass类中: <style> .myclass { /* padding-right: 1.5em; */ border: 0; background-image: linear-gradient(#034076, #034076), linear-gradient(#D2D2D2, #D2D2D2) !important; background-size: 0 2px, 100%
.myclass
类中:
<style>
.myclass {
/* padding-right: 1.5em; */
border: 0;
background-image: linear-gradient(#034076, #034076), linear-gradient(#D2D2D2, #D2D2D2) !important;
background-size: 0 2px, 100% 1px !important;
background-repeat: no-repeat !important;
background-position: center bottom, center calc(100% - 1px) !important;
background-color: transparent !important;
transition: background 0s ease-out !important;
float: none !important;
box-shadow: none !important;
border-radius: 0 !important;
font-weight: 400 !important;
border: none;
}
</style>
<p-autoComplete class="myclass" [style]="{'width':'100%'}" [inputStyle]="{'width':'100%'}" [inputStyleClass]="myclass" [(ngModel)]="country" [suggestions]="filteredCountriesSingle" (completeMethod)="filterCountrySingle($event)" field="name" [minLength]="1"></p-autoComplete>
.myclass{
/*右侧填充:1.5em*/
边界:0;
背景图像:线性梯度(#034076,#034076),线性梯度(#D2D2D2D2,#D2D2D2D2D2)!重要;
背景尺寸:0 2px,100%1px!重要;
背景重复:不重复!重要;
背景位置:中心底部,中心计算(100%-1px)!重要;
背景色:透明!重要;
过渡:背景轻松!重要;
浮动:无!重要;
盒影:无!重要;
边界半径:0!重要;
字体重量:400!重要;
边界:无;
}
尝试使用此
[styleClass]=“myclass”尝试使用此
[styleClass]=“'myclass'”关于编写主要组件的css,但也添加了主体选择器
body .ui-autocomplete .ui-autocomplete-input {
/* padding-right: 1.5em; */
border: 0;
background-image: linear-gradient(#034076, #034076), linear-gradient(#D2D2D2, #D2D2D2) !important;
background-size: 0 2px, 100% 1px !important;
background-repeat: no-repeat !important;
background-position: center bottom, center calc(100% - 1px) !important;
background-color: transparent !important;
transition: background 0s ease-out !important;
float: none !important;
box-shadow: none !important;
border-radius: 0 !important;
font-weight: 400 !important;
border: none;
}
然后在app.component中导入角度核心的视图封装
import {Component, OnInit, ViewEncapsulation} from '@angular/core';
在@component中
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
encapsulation: ViewEncapsulation.None
})
这就是改变了css的组件
关于编写主要组件的css,但同时添加主体选择器
body .ui-autocomplete .ui-autocomplete-input {
/* padding-right: 1.5em; */
border: 0;
background-image: linear-gradient(#034076, #034076), linear-gradient(#D2D2D2, #D2D2D2) !important;
background-size: 0 2px, 100% 1px !important;
background-repeat: no-repeat !important;
background-position: center bottom, center calc(100% - 1px) !important;
background-color: transparent !important;
transition: background 0s ease-out !important;
float: none !important;
box-shadow: none !important;
border-radius: 0 !important;
font-weight: 400 !important;
border: none;
}
然后在app.component中导入角度核心的视图封装
import {Component, OnInit, ViewEncapsulation} from '@angular/core';
在@component中
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
encapsulation: ViewEncapsulation.None
})
这就是改变了css的组件
谢谢,如果我已经这么做了,但由于某些原因,它不起作用。您尝试过使用额外的引号吗?像“'myclass'”一样,我忘了告诉您在组件中添加这个封装来覆盖它。我也有同样的问题。我添加了这个,并检查了我的类是否有双引号。封装:视图封装。None@Component({moduleId:module.id,选择器:“Order basic app”,templateUrl:“./orderBasicClient.component.html”,providers:[DispatchService],封装:ViewEncapsulation.None})我尝试过,但没有成功,我做了一些事情并找到了解决方案,非常感谢您所做的一切,如果我已经这么做了,我将对解决方案进行评论,谢谢,但由于某些原因,它不起作用。您是否尝试过使用额外的引号?像“'myclass'”一样,我忘了告诉您在组件中添加这个封装来覆盖它。我也有同样的问题。我添加了这个,并检查了我的类是否有双引号。封装:视图封装。None@Component({moduleId:module.id,选择器:“Order basic app”,templateUrl:“./orderBasicClient.component.html”,providers:[DispatchService],封装:ViewEncapsulation.None})我尝试过,但没有成功,我做了一些事情并找到了解决方案,非常感谢您所做的一切,我将对解决方案进行评论。您是否尝试在
p-autoComplete
中使用styleClass=“myclass”
?您是否尝试在p-autoComplete
中使用styleClass=“myclass”
?