Could add css style when printing?
See original GitHub issueI base on Vue
<template>
<div>
<div class="myclass">My Data.....</div>
</div>
</template>
<style lang="scss" scoped>
.myclass {
color: red;
}
</style>
But don’t work when printing.
Issue Analytics
- State:
- Created 6 years ago
- Comments:23 (7 by maintainers)
Top Results From Across the Web
How To Set Up A Print Style Sheet - Smashing Magazine
The good news is that a print style sheet is actually very easy to craft: you can follow a couple of simple CSS...
Read more >How to Create Printer-friendly Pages with CSS - SitePoint
The DevTools ( F12 or Cmd/Ctrl + Shift + I ) can emulate print styles, although page breaks won't be shown. In Chrome,...
Read more >CSS Printing - @media Rule - Tutorialspoint
CSS Printing - @media Rule, You can use CSS to change the appearance of your web page when it's printed on a paper....
Read more >CSS: The Perfect Print Stylesheet | The Jotform Blog
6 – Adding Messages Before and After Printing. Sometimes, it can be very useful to be able to add messages before and after...
Read more >Using CSS to Format Documents for Printing - MakeUseOf
In this example, the print.css stylesheet will only be used when the document is printed out. This is a very useful mechanism. We...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can pass
[*]
for all styles.define first your styling like
<style lang="scss" scoped> .myclass { color: red; font-size: 15px; margin: 10px auto; } </style>
and in the javascript file, add in the printJS options the targetStyles property which is an array listing all the names of the css properties you have used. for the css sample above it would be like this
printJS({printable: 'elementID', type:'html', targetStyles: ['color','font-size','margin'] })
so whatever css property that is not in that list of targetStyles will be ignored by printJS, but any property included in the array will be kept and used in the generation of the printable pdf.