How can I remove Gmail App Dark Mode stylings? - css

I'm building out an email using mjml and the design is pretty standard and not flexible to change.
In gmail the copy becomes illegible because gmail inverts the white copy to black copy.
I want gmail to keep my intended stylings, is there a method to ensuring gmail doesn't invert anything?
I've tried:
Applying !important to all the elements I require.
#media (prefers-color-scheme: dark) {} but gmail strips media queries.
<meta name="supported-color-schemes" content="light only"> no luck.
Any help would be much appreciated.
Thank you
Moe

You can do this hack:
<style type="text/css">
:root {
Color-scheme: light dark;
supported-color-schemes:light dark;
}
</style>
and include dark mode media query in your CSS:
#media (prefers-color-scheme: dark ) {
.body {
background-color: #CCCCCC !important;
}
h1, h2, h3, td {
color: #9ea1f9 !important;
padding: 0px 0px 0px 0px !important;
}
}
That being said, this will only work sometimes. To style against dark mode the best you can do is style your email in a way that won't be affected when dark mode is active.
Until there is a definitive solution (there is nothing for the time being), you either have to accept the idea that dark mode will stay active, or do what you can to style against it.
Here is a resource with more info. The world of email is still not caught up with the browser, many styles are still ignored by different clients and most solutions are experimental at best.

Related

Styling Ninja Forms button with CSS

For this website:
https://pfiservices.net/
The button in the form appears in white characters on PC. The background is also white, so it can't be read. I'm trying to style it white.
I've tried this CSS:
#nf-field-11.ninja-forms-field.nf-element{
color: #115172 !important;
}
And this one:
.themebutton #media only screen and (min-width: 768px){
color: #115172 !important;
}
And many more.
Also, I've edited the Theme CSS which makes the text inherit that white color. It keeps loading the previous version.
Nothing seems to work. I don't know what to do anymore.
I appreciate any help on this issue.

CSS Selectors like :after, :before not shown by printing

i am coding and designing an applicaition and i want that the screen mode looks in print mode same.
Here is a screenshot of the screen version:
And here ist a screenshot of the print version (e.g. on Chrome):
The timeline stripe is set by :before and that won't be printed.
Have someone an idea or an solution? Have someone a guide for css print rules?
I know it has been over a year, but here is what worked for me. When the Print Dialog appears, check to enable "Background Graphics" in the Print Dialog.
Try to put your css rules inside print media query:
#media print {
h2 {
font-size: 14px;
}
}
The problem was to adding twitter bootstrap, in the print query there was following code
*, :before, :after {
color: none !important;
text-shadow: none !important;
background: none !important;
-webkit-box-shadow: none !important;
box-shadow: none !important;
}
So i have override it by:
*, :before, :after {
color: inherit !important;
text-shadow: inherit !important;
background: inherit !important;
-webkit-box-shadow: inherit !important;
box-shadow: inherit !important;
}
And after that: change the color of your elements by !important
I had a similar problem with ::before tag, seems like it is related to enabling background graphics as Abdud suggested above. I found that adding print-color-adjust: exact; to body solved it for my case.
body {
print-color-adjust: exact;
}
Note that Chromium browsers only allow body's descendants to have background color printed. If you have background color on your body set, this solution might not be suitable for you. MSDN's has more information about how to use this property
I had a :before pseudo-class with a background-color above a div.
It was not appearing in the print version.
I don't know why but the solution for me was to set a border-top on the div on them #media print {...} version.

User style !important not taking precedence

According to the W3C, user important style declarations are supposed to have the highest priority, higher than author important declarations, but I'm not seeing that happen. If you go to jsfiddle (intentionally blank, I'm referring to the site itself), and look at the styling for the iframe, you'll see the following:
#content textarea, #content iframe
{
background: none repeat scroll 0 0 #FFFFFF;
border: 0 none !important;
box-shadow: 0 1px 3px #E4E4E4 inset;
}
I made a user style (using stylish) with the following css:
#namespace url(http://www.w3.org/1999/xhtml);
#-moz-document domain("jsfiddle.net") {
iframe
{
border: 4px solid red !important;
}
}
When I applied it, nothing happened. If I use firebug to disable the rule or remove the !important specified by jsfiddle, it works. It also works if I change the selector in my user style to #content iframe.
W3C specifically states: 3. Sort rules with the same importance and origin by specificity of selector Since the user style rule should have higher importance, specificity shouldn't have any effect here, so why does the style not apply when using only iframe as the selector?
(tested using firefox 24.2 in case that matters)
Since I haven't gotten an answer, let me give an actual example of what I'm trying to do, and why changing the selector won't help. Here's a dabblet demonstrating the exact html/css/js I'm dealing with.
The following userstyle properly applies a red border, but has no effect on the text color.
#-moz-document domain("preview.dabblet.com"){
#test
{
color: white !important;
border: 1px solid red;
}
}
Using a userstyle, how can I force the text to always be white?
You are correct that an !important declaration of origin "user" should take precedence over any declaration of origin "author", regardless of importance or specificity. However you are making an assumption that Stylish applies its styles with the "user" origin.
Since Stylish 1.4.1 for Firefox, it will apply styles with "author" origin by default. One reason for this change was compatibility with Stylish for other browsers. Their APIs only allow Stylish to add "author" origin styles, which meant that a style that worked in Firefox didn't work in Chrome. Yours is one example of where this would be the case.
The best way to fix this (and to ensure compatibility with other browsers, should you share your style on userstyles.org), is to increase the specificity of your selector to something greater than that of the site's CSS. The simplest way to do so would be to use the same selector as the site, but add a body type selector at the start:
#namespace url(http://www.w3.org/1999/xhtml);
#-moz-document domain("jsfiddle.net") {
body #content iframe {
border: 4px solid red !important;
}
}
There are cases where this isn't feasible: a style that affects iframes on many sites that couldn't be so specific with its selector, or a style trying to override an !important declaration inside an HTML style attribute. Stylish for Firefox allows you to switch your style to the "agent" origin with a special comment: /* AGENT_SHEET */. This will have the effect of your !importants beating anything the site can do (much like the "user" origin), but it will not work in other browsers and can cause bad things like crashes, so this is only suggested if the above method is completely unworkable for you.
All of this is described on Stylish's wiki along with some info less relevant to your situation.
You're right on with the specificity idea. The problem is both your rule and jsfiddle's rule use !important which means both rules have the same priority, but the #content textarea, #content iframe rule is more specific.
To solve, you could write your rule as:
#content iframe {
border: 4px solid red !important;
}
See this for more details: http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/#CSS_parsing
That section will give you what you need, but the whole article is extremely interesting.

Hyperlink in email on mobile only with CSS3

I am looking to add a hyperlink in a HTML email but only on mobile through CSS3. Is there any CSS3 property to do that?
This is not possible via CSS.
You have a couple options:
Something like <span class="mobile">The link</span><span class="desktop">No link</span> plus a #media query to show/hide the two spans on different device sizes.
Style the link on desktop via a #media query so it looks like normal text (i.e. color: #000; cursor: default; text-decoration: none;)
ceejayoz is pretty close. You just have to reverse your thinking a little bit.
If you're only putting the hyperlink on mobile/smaller screens this can be done easily with inline css and an #media query in the <head>. (Note. I would recommend sending the emails through an Email Service Provider to make sure your #media query remains untouched.)
This is the approach I would take.
CSS
#media only screen and (max-width: 480px){
a[class="link"] {
font-size: 12px !important;
color: #000001 !important;
text-decoration: underline !important;
}
}
HTML
<a class="link" href="http://yourlink.com" style="font-size: 1px; color: #ffffff; text-decoration: none;">yourlink.com</a>
I should also mention not all mobile email clients will recognize the #media query properly. Gmail on Android for example doesn't work very well when developing responsive HTML emails.

Print command in chrome doesn't apply css style

I need to draw a small vertical seperating line in my print document. When i apply it thro the CSS class ,it works pretty well with firefox and IE8, but the styles dont get applied for chrome. The styles are in #media print of my css file.
.verticalLine1
{border:0.5px #B1B1B1;
border-style:solid;
border-top-width:15px;
width:1px;
}
Any pointers to solve this problem?
Try this in your CSS file:
.verticalLine1 {
visibility: hidden;
border: 0.5px #B1B1B1;
border-style: solid;
border-top-width: 15px;
width: 1px;
}
#media print {
.verticalLine1 {
visibility: visible;
}
}
and include CSS file without media="screen" attribute and without any JavaScript click event
<link href="styles/print.css" rel="stylesheet" type="text/css"/>
After 2 pathetic days, I couldn't crack up with a proper fix.But had few alternatives
Writing styles inline with the code worked Pretty perfectly. Code looks as below
<div style="border:0.5px #B1B1B1;border-style:solid;border-top-width:15px;width:1px;"></div>
Since the previous approach is not a great coding practice I was forced to create an image with the above dimensions and I added it as a part of the code.
Thanks to chrome.Atleast it adds images, if not css.
Adding images for borders is never a good idea. Also, you need to keep in mind that chrome truncates the decimal values to closest lower number. Due to this 0.5px will be interpreted as 0px instead. I will suggest use 1px instead of 0.5px. This will remove so many issues.

Resources