text-shadow and box-shadow while printing (Chrome)

前端 未结 6 1294
礼貌的吻别
礼貌的吻别 2021-01-17 12:44

I\'m making some printable calendar website using HTML, CSS and JS.

Unfortunately I cannot use CSS property called text-shadow, because shadow behind te

6条回答
  •  南笙
    南笙 (楼主)
    2021-01-17 13:28

    I realise this is an old question, but just to note that it is possible to make shadows print correctly in Chrome. You need to set both -webkit-print-color-adjust and a filter, as found in this bug thread: https://code.google.com/p/chromium/issues/detail?id=174583

    .thing {
        -webkit-print-color-adjust:exact;
        -webkit-filter:opacity(1);
    }
    

    (I prefer to set opacity rather than blur as used in the bug, simply because it seems likely to cause fewer problems).

    Note that this will limit the resolution of the print (filter makes it send a rasterised version), so text might become harder to read. If you really want to work around that, I'd suggest duplicating the div (one for the shadow, with the filter hack and transparent text, and another for the text with no shadow)

提交回复
热议问题