I'm having such a weird problem with a html of a mail marketing newsletter when receiving the email on apple mail (osx and ios- both latest) on dark mode. I add the media queries and everything works perfect from light to dark, images changes perfectly but theres an anoying problem with tags.
I'm using my cta buttons as but i cannot by any means to add a background color to the and change ist's text color, this only on dark mode. On light everything works as it should. I send the images of the button in ligt and dark for better understanding as well my inline code and my css code. I've tried with span in text, without, with borders, with padidings, etc etc, everything i could remember. On any browser dark and light works great.
Hope someone can help me.
Many thanks
#media (prefers-color-scheme: dark) {
a.nos-button,
a.nos-button span{
background-color: #fff !important;
background: #fff !important;
border-color: #fff !important;
color: #000 !important;
}
}
#media (prefers-color-scheme: light) {
a.nos-button,
a.nos-button span{
background-color: #000 !important;
background: #000 !important;
border-color: #000 !important;
color: #fff !important;
}
}
<span>COMPRE JÁ</span>
I ran into what appears to be a weird bug in chrome.
.dropcap {
font-size: 150%;
}
section p::first-letter {
font-size: 150%;
/*#apply dropcap*/
}
*::-moz-selection, .dropcap::-moz-selection {
background: #f7941d !important;
}
*::selection, .dropcap::selection {
background: #f7941d !important;
}
/* *::-moz-selection {
background: #f7941d !important;
}
*::selection {
background: #f7941d !important;
} */
<section>
<p>hello world</p>
</section>
I've tried adding !important and targeting all elements *, targeting the dropcap class, etc. My setup is with tailwind and jekyll, but this bug appears in plain HTML, CSS & JS.
I'm wondering how to change the selection color (other than individually adding a dropcap class to every single starting character in every paragraph on the website)
Some more examples of this bug:
Chrome:
Firefox:
Deleting lines 5-8 (styles applied to first-letter) in chrome:
The dropcap is still a larger font-size, but the selection color now works. I'm wondering why this is and if I can somehow style dropcaps without screwing up the selection color or adding a span with a class to every single first character of every single paragraph on every single page of the website.
When I use bootstrap, it removes the background color from everthing when I try to print my page.
Almost everything on my website is using bootstrap classes so I want to avoid a lot of manual CSS outside bootstrap.
I've found out that bootstrap uses #media print to remove the background color. I'm using a bootstrap theme as well (theme united) which is removing the background color as well.
theme-united.css
#media print
*, *:before, *:after {
background: rgba(0, 0, 0, 0) !important;
color: rgb(0, 0, 0) !important;
-webkit-box-shadow: none !important;
box-shadow: none !important;
text-shadow: none !important;
bootstrap.min.css
#media print
*, :after, :before {
color: rgb(0, 0, 0)!important;
text-shadow: none!important;
background: 0 0!important;
-webkit-box-shadow: none!important;
box-shadow: none!important;
Is there a way to make sure that the background color is not removed when printing without editing these 2 CSS files?
For example:
When I use .alert-danger, I want that alert danger printed as it is displayed on screen, so would be printed as a red box.
See JSFiddle:
http://jsfiddle.net/7mtk7wrh/
Unfortunately there is not a good answer to your question - but maybe if you understand the why's then you can choose a way forward.
Why?
It's true that Bootstrap uses the #media print { * { color: $fff; background: transparent; }} -- but there is a very solid reason. This bit of code is actually derived from the normalizer.css project (by a then college of #mdo 's, #necolas) - it's intent is to make all browsers behave the same. These guys chose to "normalise" the css for a very good reason:
With most browsers one can choose to include or exclude background color, so the behaviour is not standard across even the same browser. Imagine for a sec a website with very dark background with white text - when printing with backgrounds off, it will look like you're printing nothing - when actually you're printing white text on no (white) background.
There was no way to account for all the different uses of color, so they choose to go black (font) and white (background, actually 'transparent'). Even the choice of black was well thought of -- its a better print solution, as most color printers have more black "ink/toner" (more economical) and they don't need to mix color to make black (so faster).
Remember that Bootstrap is also a "framework" - so a starting point if you will - and kudos to #mdo and #necolas for having the foresight to think of this in terms of establishing a predictable baseline. (No, I don't know them.)
Nope...
So the thinking here is: "what if we could 'go back' and unset this. Unfortunately CSS does not work like that - yes browsers load the CSS declarations in a "queue" where the last declaration wins (LIFO, or last-in-first-out), but I'm not aware of a way to remove this stack. So CSS developers just add more to the end...
So one would assume that we can go back that way --- add a * { background-color: inherit }. Problem is that inherit reverts to the parent property, but * is the root, so it has nothing to revert to. Same goes for initial!
Maybe!
So we're left with 4 options, none of them is what you where hoping for, but it is what it is. In order of difficulty:
Download the BS (less or sass) source, edit the offending code, and then compile it. (You need to use a local copy, CDN's will not work.)
Download the CSS variant of your choice, search and delete the offending code. (No CDN's again.)
Use getbootstrap.com/customize to create a new variant - exclude "Print media styles" under "Common CSS". (Again, no CDN's)
Override the specific items who's color you want to print: e.g.
#media print {
.alert-danger {
color: yellow !important;
background-color: red !important;
}
}
CDN's copies of BS will now work, but then you have the problem of the user possibly not printing backgrounds and having the output white (yellow in the e.g.) on white!
Finally
Well I hope learning the why's was at the very least a way of you thinking of a workaround. General rule of thumb I follow is that when printing, the background is (should be) always white. When constrained that way you start thinking of novel ideas, like exclamation icons around the text that only "print" (#media only screen { .hidden-screen { display: none; }})
Despite !important usage being generally frowned upon, this is the offending code in bootstrap.css
.table td,
.table th {
background-color: #fff !important;
}
Let's assume you are trying to style the following HTML:
<table class="table">
<tr class="highlighted">
<th>Name</th>
<th>School</th>
<th>Height</th>
<th>Weight</th>
</tr>
</table>
To override this CSS, place the following (more specific) rule in your stylesheet:
#media print {
table tr.highlighted > th {
background-color: rgba(247, 202, 24, 0.3) !important;
}
}
This works because the rule is more specific than the bootstrap default.
You can get this working by removing those lines from bootstrap.css file, there might be a jquery solution to this but it is much more complicated than erasing a few lines. :/
Or you could use a plugin called html2canvas as presented in this jsfiddle
I ended up here with the same problem but found the Chrome comes with a show background graphics option on the print dialog under more settings that did exactly that! No modification of Bootstrap (4) required.
#Vino explained really well. I was also facing problem because bootstrap.css makes background transparent forcefully. Thus I have customized the specific element in my custom CSS file. Remember to change <.element> with element where you want the colorful background instead of transparent.
#media print {
.element{
background-color: white !important;
box-shadow: inset 0 0 0 1000px #fff !important; /* workaround for IE 11*/
}
}
i had also face the same problem.. i just remove the bootstrap.min.css from my code then it work for me.
just make the specificity-value more specific and you should be ok.
something like:
#media print {
tbody>tr:nth-child(even)>td {
background-color: rgb(230, 216, 216) !important;
}
}
Actually, there is a solution, but this is still a hack.
It was used for a pdf generation in puppeteer, so it was tested only in this case, but most probably should work in all modern browsers.
Keep in mind that BOOTSTRAP_PRINT_RULE can be different in a different version of Bootstrap.
const BOOTSTRAP_PRINT_RULE = `#media print {
*, ::after, ::before { color: rgb(0, 0, 0) !important; text-shadow: none !important; background: 0px 0px !important; box-shadow: none !important; }
a, a:visited { text-decoration: underline; }
a[href]::after { content: " (" attr(href) ")"; }
abbr[title]::after { content: " (" attr(title) ")"; }
a[href^="javascript:"]::after, a[href^="#"]::after { content: ""; }
blockquote, pre { border: 1px solid rgb(153, 153, 153); break-inside: avoid; }
thead { display: table-header-group; }
img, tr { break-inside: avoid; }
img { max-width: 100% !important; }
h2, h3, p { orphans: 3; widows: 3; }
h2, h3 { break-after: avoid; }
.navbar { display: none; }
.btn > .caret, .dropup > .btn > .caret { border-top-color: rgb(0, 0, 0) !important; }
.label { border: 1px solid rgb(0, 0, 0); }
.table { border-collapse: collapse !important; }
.table td, .table th { background-color: rgb(255, 255, 255) !important; }
.table-bordered td, .table-bordered th { border: 1px solid rgb(221, 221, 221) !important; }
}`
for (const styleSheet of document.styleSheets) {
for (const [index, rule] of Array.from(styleSheet.cssRules).entries()) {
if (rule.cssText && rule.cssText.includes(BOOTSTRAP_PRINT_RULE)) {
styleSheet.deleteRule(index)
return;
}
}
}
Since version 4 of Bootstrap with SASS you can actually set the following variable to false which will turn of this behavior:
$enable-print-styles: false
If this is not an option, there is the following script which brutally rips out all #media print annotations from the CSS. It assumes that Bootstrap is the first style sheet loaded and that it runs after Bootstrap has loaded.
var style = document.styleSheets[0];
[].forEach.call(style.cssRules || [], function (aRule, aIndex) {
if (aRule.cssText.indexOf("#media print") >= 0) {
style.deleteRule(aIndex);
}
});
You can use this (https://developer.mozilla.org/fr/docs/Web/CSS/print-color-adjust)
.your-selector {
-webkit-print-color-adjust: exact;
}
Warning: This is not standart, but might help you.
I have created carousel arrows using font-icons and they are appearing as required on Firefox and Chrome on my system even I have checked it on my android and they are showing the same result as red color arrows generated by the font-icons.
But when someone is looking at the website on iPhone in the safari browser it is not showing these buttons properly, instead it is showing blue background and white color arrow on it.
I am using font-icons for generating these arrows in my code and I have thoroughly checked my CSS several times but no luck.
Here is my CSS for these buttons:
body.home .et-pb-arrow-next::before, body.home .et-pb-arrow-prev::before {
color: #ff0000 !important;
display: block !important;
margin-top: -35px !important;
}
body.home #main-content .et-pb-arrow-prev::before {
content: "\25C0" !important;
font-size: 40px !important;
}
body.home #main-content .et-pb-arrow-next::before {
content: "\25b6" !important;
font-size: 40px !important;
}
Having always many, many, many Komodo tabs open, I would appreciate to find some solution to adjust the tabbar layout. The font size for example.
Of course, in Komodo preferences I am able to change the font properties, related to the tab content. But this is NOT exactly what I am looking for.
I would like to change font properties of the TAB ITSELF in order to see more tabs on my screen without any scrolling.
AFAIK this is not possible in Komodo preferences GUI.
Is there any other solution? (e.g. editing some komodo config file)
While waiting for a multirow tab option in future releases, my quick workaround to mitigate this issue was to declare in the 'userChrome.css' the following rules:
#tabbed-view tabs > tab {
font-size: 10px !important;
max-width:70px !important;
}
#tabbed-view tabs > tab:hover {
max-width:none !important;
background-color: #bfe0f8 !important;
}
#tabbed-view tabs > tab[selected="true"] {
max-width:none !important;
font-weight: normal !important;
color: #cc0000 !important;
}
#tabbed-view tabs > tab[selected="true"]:hover {
background-color: #ecbebe !important;
}
#tabbed-view .tab-text {
margin-left: -17px !important;
}
.tab-icon {
width: 0px !important;
height: 0px !important;
}
if you're not familiar with css, basically these rules do:
hide the icon tab image on the left so to gain a bit more space for the label-text (now positioned some pixels to the left and reduced in size).
the width of the tabs are max 70px, except for the selected one and on mouse over. In those 2 cases it's auto.
Use a userChrome.css file with a rule such as this:
tabs > tab[selected="true"], tabs > tab[selected="true"]?
{
font-size: 10px; font-weight: bold;
}
Alternatively, use a macro:
ko.views.manager.currentView.parentNode._tab.style.cssText = 'font-size: 10px; font-weight: bold';