Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS/SCSS/bootstrap :: override print settings in bootstrap :: change background:transparent ! important to a color

Tags:

I have a problem with the bootstrap CSS/print.

In bootstrap CSS (reset.css) everything is cleared for printing

@media print {   * {     text-shadow: none !important;     color: black !important;     background: transparent !important;     box-shadow: none !important;   } } 

But I have to print several lines in color. My table looks like this:

<div class="container">     <div id="task-summary">         <div id="process-summary">             <table class="table table-condensed">                 <tbody>                     <tr class="success">                         <td> 

I embeded this into my code, but it does not work:

@media print {    #task-summary{     .success{       background-color: #DFF0D7 !important;     }   } } 

I've already tried if the css is excepted by using display: none .. it works (line is not displayed) and seems to be on the right place.

Does someone have an idea how I can manage to override the bootstrap css command, without editing the reset.css of bootstrap?

like image 449
jabbawock Avatar asked Mar 27 '13 12:03

jabbawock


People also ask

How do I override Bootstrap CSS variables?

Override Variables Bootstrap has its own “_variables. scss” in the “scss” folder, which contains all variables used in Bootstrap. Now, add the “abstracts” name folder in your scss folder and create “_custom-variables. scss” in that folder.

Can I use Sass with bootstrap?

Bootstrap includes a handful of Sass maps, key value pairs that make it easier to generate families of related CSS. We use Sass maps for our colors, grid breakpoints, and more. Just like Sass variables, all Sass maps include the ! default flag and can be overridden and extended.

Which one is recommended for overwriting bootstrap styles?

Can you override Bootstrap CSS? If you want to customize your Bootstrap site, leave the source code as-is and simply add custom code in an external stylesheet. The code in this external stylesheet will override the existing styles, as long as it's set up properly.


2 Answers

I had the same problem. When you print the page the background-color: ...; option doesn't work at table rows. Change the CSS-Selector to:

@media print {    #task-summary .success td {     background-color: #DFF0D7 !important;      /* add this line for better support in chrome */      -webkit-print-color-adjust:exact;   } } 

Everything should work after this changes.

like image 103
phylib Avatar answered Sep 18 '22 14:09

phylib


@media print {     .success {       background-color: #DFF0D7 !important;     }     } 

Or

@media print {     #task-summary .success {       background-color: #DFF0D7 !important;     }   } 

Or

@media print {     #task-summary > #process-summary .success {       background-color: #DFF0D7;     } } 
like image 20
GaryP Avatar answered Sep 21 '22 14:09

GaryP