选中时,复选框的十字标签

时间:2019-08-01 10:10:55

标签: css angular checkbox primeng

我在检查时如何使用CSS横穿Primeng复选框的标签:

<p-checkbox value="test" label="test"> </p-checkbox>

我的复选框:

enter image description here

需要复选框:

enter image description here

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>
<div _ngcontent-taj-c2="" class="ui-g-11" style="padding: 0%;margin: 0%">
  <p-checkbox _ngcontent-taj-c2="" id="a" value="t.name" ng-reflect-value="t.name" ng-reflect-label="test">
    <div class="ui-chkbox ui-widget" ng-reflect-ng-class="ui-chkbox ui-widget">
      <div class="ui-helper-hidden-accessible">
        <input type="checkbox" ng-reflect-ng-class="[object Object]" name="undefined" value="t.name">
      </div>
      <div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default" ng-reflect-klass="ui-chkbox-box ui-widget ui-cor" ng-reflect-ng-class="[object Object]">
        <span class="ui-chkbox-icon ui-clickable" ng-reflect-klass="ui-chkbox-icon ui-clickable"></span>
      </div>
    </div>
    <label class="ui-chkbox-label ng-star-inserted" ng-reflect-ng-class="[object Object]">test</label>
  </p-checkbox>
</div>

2 个答案:

答案 0 :(得分:1)

样式c复选框,带有css属性text-decoration: line-through;时选中

答案 1 :(得分:1)

如果您选中Checkbox的documentation,您会看到它具有ui-label-active类,可以使用。

::ng-deep .ui-label-active  {
  text-decoration: line-through;
}

添加:: ng-deep以便能够从组件中访问元素很重要。

如果要全局更改,可以将其放在styles.css上。只需确保在primng样式(在angular.json中)之后将其导入

"styles": [
  "node_modules/primeng/resources/themes/nova-light/theme.css",
  "node_modules/primeng/resources/primeng.min.css",
  "src/styles.css"
],

styles.css

.ui-label-active    {
  text-decoration: line-through;
}