question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues using external stylesheet

See original GitHub issue

I use print.js to print my html page. But why the text color can’t be printed? The rest css style is no problem.

My CSS

#tax td{
      color: #518cb8 !important;
}

My print.js

$(function(){
            printJS({
                printable: 'print-area',
                type: 'html',
                css: ['https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',
                      'https://fonts.googleapis.com/css?family=Open+Sans:400,700'
                ],
                targetStyles: ['*']
            });
        });

My html

<table>
    <tfoot>
         <tr id="tax">
                <td colspan="4">Tax Base</td>
                <td class="text-right">5000</td>
         </tr>
     </tfoot>
</table>

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
crabblycommented, Mar 5, 2019

Hi @conangithub,

Try passing all your css through the css property, and disable the library style processing.

Ex.:

printJS({
    printable: 'print-area',
    type: 'html',
    css: [
    	'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',
      	'https://fonts.googleapis.com/css?family=Open+Sans:400,700'
      	'/css/my-website-stylesheet.css'
    ],
    scanStyles: false
})

This will also be faster since it prevents the client / library from running some javascript code to retrieve all the applied style on your html.

0reactions
melancholyfleurcommented, Nov 13, 2019

Update: I was able to just make the changes directly to the file in my local repo to see if they work. The change does seem to help load the fonts internal to the application inside the iframe. Would you be able to either put together a PR with that commit or review one if I put it together, @crabbly?

Read more comments on GitHub >

github_iconTop Results From Across the Web

html - External CSS not working
As soon as I outsourced my CSS code in an external file, the exact same problem came across. For me the problem was...
Read more >
How to fix CSS not linking to your HTML document
When you add an external CSS file to your HTML document, you need to add the rel="stylesheet" attribute to the <link> tag to...
Read more >
Help! My CSS Isn't Working!
Another place you might run into problems is in trying to use external stylesheets. First, using @import is risky at best, because Netscape...
Read more >
text-align problem CSS: External Style Sheets, Identifying ...
In the CSS you need to have a rule for #subheader (the # is for selecting an element by its id attribute), and...
Read more >
How to Fix CSS file is not Working with HTML in Chrome
Fix CSS file is not Working with HTML in Chrome | Problem Solved Show SupportBuy Me a COFFEE: https://buymeacoffee.com/Webjahin  ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found