简体   繁体   中英

How can I change CSS '@media print' styles in jQuery?

I am dynamically setting the offset of an html element where position: relative . I use the following code (in pure js but jQuery is ideal for me):

document.querySelector('#overlay-marker-report').style.left = Math.floor(cli.getXLocation(period)) + 134 + "px";

For print, this offset has to change or things don't align properly. Is there a way to do what I am doing but for print specifically?

You can try using matchMedia . If that doesn't suite your needs you can change some CSS property on #overlay-marker-report (eg float) and test if @media is print that way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM