0

When I load my page I set the margin of the container div with Javascript to avoid that the page 'jumps' when the scrollbar shows. Hence, the default value is auto - but the actual value is defined with JS

However, when I then want to print the page, I would like the margins to be set back to auto (or some chosen value)

I have tried with:

@media print { .container { margin: 0px; }}
@page { .container { margin: 0mm 0mm 0mm 0mm; }}

And with an independent style sheet for media="print" with:

.container { margin: 0px; }
4

1 回答 1

2

所以你想覆盖 JavaScript 设置的内联样式?

media="print"在你的样式表中试试这个:

.container { 
    margin: 0px !important; 
}

!important除非您指定规则,否则内联样式优先于样式表。

于 2012-12-18T11:27:51.920 回答