使用角,我在一个组件中使用p日历,并创建了一个从我的组件中调用的CSS类。无论我做什么,我都无法推翻这种风格。
CSS
.ui-calendar .ui-calendar-button {
height: 34px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
width: 900em;
border-left: 0 none;
}<div class="form-group col-xs-3 col-md-3"
[ngClass]="{
'has-error':(ersaForm.get('effectiveDt').touched || ersaForm.get('effectiveDt').dirty ) &&
!ersaForm.get('effectiveDt').valid
}">
<label for="effectiveDtId" class="control-label">Effective Date</label><br />
<p-calendar formControlName="effectiveDt" id="effectiveDtId" [showIcon]="true"
inputStyleClass="form-control "
class="ui-calendar ui-calendar-button"
[style]="{'width': '100%','display': 'inline-flex','height':'34px'}" ></p-calendar>
</div>****************************************************UPDATE****************************************
我将SCSS文件更改为
::ng-deep .only-style-this .ui-calendar .ui-calendar-button {
height: 34px !important;
border-top-left-radius: 0 !important;
} <div class="form-group col-xs-3 col-md-3 only-style-this"
[ngClass]="{
'has-error':(ersaForm.get('effectiveDt').touched || ersaForm.get('effectiveDt').dirty ) &&
!ersaForm.get('effectiveDt').valid
}">
<label for="effectiveDtId" class="control-label">Effective Date</label><br />
<p-calendar formControlName="effectiveDt" id="effectiveDtId" [showIcon]="true"
inputStyleClass="form-control"
styleCalss=".ui-calendar .ui-calendar-button"
[style]="{'width': '100%','display': 'inline-flex','height':'34px'}" ></p-calendar>
</div>警告
验证(CSS3.0):“:ng-深度”不是有效的伪元素。
发布于 2018-10-09 14:37:44
您不能调整子组件的css,它破坏了封装。这是可行的,但是已弃用
::ng-deep .ui-calendar .ui-calendar-button {
height: 34px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
width: 900em;
border-left: 0 none;
}这与将其添加到全局样式表本质上是一样的。但是,只有当组件第一次加载时,全局样式才会应用,这使其更加糟糕。为了安全起见,您可以将组件包装在一个“只有样式-此”类中,然后执行以下操作:
::ng-deep .only-style-this .ui-calendar .ui-calendar-button {
...
}或者,素-ng通常允许您传递样式与其大多数组件。
如果您查看文档,您会发现有一个样式属性可以使用。您可能还需要使用其他属性,如inputStyle。
发布于 2021-11-11 09:09:46
我在文件style.css (角cli )中使用素数ng ver12.xx覆盖这个ok
.p-datepicker table td{ padding: 0px; }
.p-datepicker table td > span { height: 45px;width: 50px; }发布于 2021-12-16 13:33:47
如下所示,https://forum.primefaces.org/viewtopic.php?t=53756只是将样式作为列表项放在angular.json文件中的样式数组中
"styles": [
"../node_modules/primeng/resources/primeng.min.css",
"../node_modules/fullcalendar/dist/fullcalendar.min.css",
"../node_modules/quill/dist/quill.snow.css",
"../node_modules/nanoscroller/bin/css/nanoscroller.css",
"styles.css"
],然后你就可以自由使用你的css了。
https://stackoverflow.com/questions/52723585
复制相似问题