IE11忽略@page规则? [英] IE11 Ignoring @page rule?

查看:484
本文介绍了IE11忽略@page规则?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在我正在列印的网页上设定边距。在铬,它看起来不错。 IE不是这么多。我尝试设置的边距如此:

I'm trying to set the margins on a page that I am printing. In chrome, it looks great. IE not so much. I'm trying to set the margins like so:

@media print {
    @page {
        margin: -0.5cm;
        margin-left: -1.5cm;
        margin-right: -1.5cm;
    }
}



我参考了css文件head:

I'm referencing the css file like this in the head:

<link rel="stylesheet" href="Content/print.css" type="text/css" media="print">

我可以通过调整边距值来调整Chrome的边距,但在IE11 ,它似乎完全忽略了这个....

I'm able to adjust the margins just fine in chrome by tweaking the margin values, but in IE11, it seems to be completely ignoring this....

我做错了什么?

推荐答案

@page选择器不需要嵌套,因为页面上下文

The @page selector does not need to be nested, since the page context is assumed:


@page规则中的声明被认为是在页面上下文

The declarations in an @page rule are said to be in the page context.

负边距为 user-agent 特定:


在页面框上或在元素上)或绝对定位内容可以在页面框之外结束,但是该内容可以由用户代理,打印机或最终切割器切割。

Due to negative margin values (either on the page box or on elements) or absolute positioning content may end up outside the page box, but this content may be "cut" — by the user agent, the printer, or ultimately, the paper cutter.

此外, CSS语法没有定义嵌套规则的行为。

In addition, the CSS grammar does not define the behavior of nested at-rules.


The productions are:

stylesheet
  : [ CHARSET_SYM STRING ';' ]?
    [S|CDO|CDC]* [ import [ CDO S* | CDC S* ]* ]*
    [ [ ruleset | media | page ] [ CDO S* | CDC S* ]* ]*
  ;
import
  : IMPORT_SYM S*
    [STRING|URI] S* media_list? ';' S*
  ;
media
  : MEDIA_SYM S* media_list '{' S* ruleset* '}' S*
  ;
media_list
  : medium [ COMMA S* medium]*
  ;
medium
  : IDENT S*
  ;
page
  : PAGE_SYM S* pseudo_page?
    '{' S* declaration? [ ';' S* declaration? ]* '}' S*
  ;
pseudo_page
  : ':' IDENT S*
  ;
operator
  : '/' S* | ',' S*
  ;
combinator
  : '+' S*
  | '>' S*
  ;
unary_operator
  : '-' | '+'
  ;
property
  : IDENT S*
  ;
ruleset
  : selector [ ',' S* selector ]*
    '{' S* declaration? [ ';' S* declaration? ]* '}' S*
  ;
selector
  : simple_selector [ combinator selector | S+ [ combinator? selector ]? ]?
  ;
simple_selector
  : element_name [ HASH | class | attrib | pseudo ]*
  | [ HASH | class | attrib | pseudo ]+
  ;
class
  : '.' IDENT
  ;
element_name
  : IDENT | '*'
  ;
attrib
  : '[' S* IDENT S* [ [ '=' | INCLUDES | DASHMATCH ] S*
    [ IDENT | STRING ] S* ]? ']'
  ;
pseudo
  : ':' [ IDENT | FUNCTION S* [IDENT S*]? ')' ]
  ;
declaration
  : property ':' S* expr prio?
  ;
prio
  : IMPORTANT_SYM S*
  ;
expr
  : term [ operator? term ]*
  ;
term
  : unary_operator?
    [ NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S* | ANGLE S* |
      TIME S* | FREQ S* ]
  | STRING S* | IDENT S* | URI S* | hexcolor | function
  ;
function
  : FUNCTION S* expr ')' S*
  ;
/*
 * There is a constraint on the color that it must
 * have either 3 or 6 hex-digits (i.e., [0-9a-fA-F])
 * after the "#"; e.g., "#000" is OK, but "#abcd" is not.
 */
hexcolor
  : HASH S*
  ;

这篇关于IE11忽略@page规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆