【问题标题】:Use CSS Detect Page Orientation in Printing在打印中使用 CSS 检测页面方向
【发布时间】:2015-05-28 09:52:33
【问题描述】:

我想使用 CSS 样式来检测打印中的页面方向,然后在用户选择不同的方向(横向或纵向)时应用不同的样式。

@media print{ /*portrait*/  /*landscape*/}

有什么办法吗?

谢谢

【问题讨论】:

  • 等等...打印出来后会有什么不同?目前尚不清楚用例是什么,您是否正在尝试这样做 - stackoverflow.com/questions/20361384/…
  • @Paulie_D 这似乎是相同的一般想法,除了不是测试特定尺寸,它只是测试宽度是否大于高度,反之亦然。

标签: css printing orientation


【解决方案1】:

使用orientation: ... 媒体选择器。这是一个例子:

@media print and (orientation: portrait) {
    /* Your code for portrait orientation */
}
@media print and (orientation: landscape) {
    /* Your code for landscape orientation */
}

【讨论】:

  • 没问题,很高兴能帮上忙!祝你好运!
  • 你可以嵌套媒体查询@media print { @media (orientation: landscape){ } @media (orentation: portrait) { } }
猜你喜欢
  • 1970-01-01
  • 2013-08-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-13
  • 2017-02-15
  • 2011-04-04
相关资源
最近更新 更多