css - 自动展开所有 PrimeNG Accordion 面板以进行打印

标签 css angular typescript media-queries primeng

我目前在我的 Angular 元素中使用 PrimeNG 库的 Accordion 组件。 See info here .

该模板包含一些用于打印页面的特殊 css 样式——如下所示:

 @media print {
  .profile-progress-bar, .top-template-header-content, .header.profile-header{
    display: none !important;
  }
  html, body {
    height: auto;
    font-size: 10px !important;
  }

  p-accordionTab > div {
    display: block !important;
    selected: true !important;
  }

}

我想做的是,在为要打印的页面处理 @media print 渲染时,自动展开所有 accordionTab 元素。

从文档中我看到每个 accordionTab 元素都有一个 [selected] 属性,可以将其绑定(bind)并设置为“true”以展开选项卡。

Selected Visibility of the content is specified with the selected property that supports one or two-way binding.

但是,当 @media print 渲染发生时,这能以某种方式自动触发吗?

谢谢!

最佳答案

媒体查询是可行的方法,您可以采用纯 CSS 方法来实现; TS 或 HTML 文件没有变化

相关css:

@media print {
  ::ng-deep .ui-accordion-content-wrapper-overflown {
      overflow: visible;
      height: auto !important;
  }
}

完成demo on stackblitz here

enter image description here

关于css - 自动展开所有 PrimeNG Accordion 面板以进行打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56352717/

相关文章:

javascript - 本地存储 : Storing data individually VS one big String?

javascript - typescript :可能导致此错误的原因是什么? "Element implicitly has an ' 任何类型,因为类型 'Object' 没有索引签名”

javascript - JavaScript 表单中的边框颜色不会覆盖

html - 没有相对位置的圆 Angular

javascript - ngFor 中的 Angular2 组件抛出错误(viewFactory 不是函数)

node.js - 错误 : node_modules/preact/src/jsx. d.ts:2138:24 - 错误 TS2304:找不到名称 'SVGMPathElement'

html - 在 React 的 onFocus 期间区分键盘和鼠标事件

html - 如何使用div创建表格

html - 非均匀网格 float

angular - ngModel 在 Angular4 中不起作用