iOS Outlook App only allowing a single media query in HTML email - css

I am wanting to change the font size of some text in an HTML email at 2 different screen widths with media queries. This works as expected on all devices/clients except in Outlook App for iOS.
Here is an example of the inline HTML:
<td class="para" align="left" style="border-collapse: collapse; mso-line-height-rule: exactly; font-family: Times, 'Times New Roman', serif; font-size: 17px; color: #333333; line-height: 24px; text-align: left; text-indent: 29px; padding: 20px 0 0 0;"><span style="font-family: Times, 'Times New Roman', serif !important;">some text here</span></td>
Then I have the following CSS:
<style>
#media only screen and (max-width:600px) {
.para {
font-size: 18px !important;
}
}
#media only screen and (max-width:445px) {
.para {
font-size: 20px !important;
}
}
</style>
If I only have one of the media queries, it works as expected in the Outlook App for iOS, but when I add the second one it no media queries work at all.
Am I doing something wrong or is this just something that you have to work around with iOS Outlook?

The issue is due to a bug in their implementation, as documented here: https://github.com/hteumeuleu/email-bugs/issues/92
The easiest solution, since perhaps your minifying code may be removing whitespace and creating the double curly braces, }}, is to close the style block and start a new one, i.e.:
<style>
#media only screen and (max-width:600px) {
.para {
font-size: 18px !important;
}
}
</style>
<style>
#media only screen and (max-width:445px) {
.para {
font-size: 20px !important;
}
}
</style>

Related

Difficulty with changing CSS button with media query

This should be basic but I am struggling with it:
My markup is simple:
<p>
sort / search all events in United States
</p>
And this CSS works well - BUT - in a small screen there is too much text so I am just trying to lower the size of the font, should be simple enough but I can't get it to work.
.button {
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0px;
font-family:inherit;
color: #393939 !important;
font-size: 16px;
background: #c8d6e5;
padding: 8px 18px 8px 18px;
border: solid #ffffff 2px;
text-decoration: none;
text-transform: uppercase;
}
.button:hover {
background: #9facb5;
text-decoration: none;
}
#media screen and (min-width: 1251px) {
 .button {
font-size: 12px !important;
 }
}
Am I doing something obviously wrong here?
Thanks
#media screen and (min-width: 1251px) will only apply styles at 1251px wide and up. If you want to apply styles to smaller screens only, you'll need to use max-width instead, which has the opposite effect.
Alternatively, you could apply the smaller font size by default without a media query, and then use the min-width query to increase the size at larger widths.

Override original CSS with media query

I created an article header css code, from a post, I got solutions to how to fix the header from overlapping by changing
#Article_Header2 {
height: 48px;
font: normal normal normal normal 16px / normal 'Roboto Condensed', sans-serif;
margin: 0px;
}
to
#Article_Header2 {
min-height: 48px;
font: normal normal normal normal 16px / normal 'Roboto Condensed', sans-serif;
margin: 0px;
}
Changing to min-height: 48px works perfectly for mobile but doesn't work for desktop. I would like to change that to only apply when it's on a mobile device.
May I ask where am I going wrong. I tried the folling.
#media (max-width:767px) {
body #Article_Header2 {
min-height: 48px;
font: normal normal normal normal 16px / normal 'Roboto Condensed', sans-serif;
margin: 0px;
}
}
When that's applied, the min-height is applied to desktop as well. I'm wondering how can I set min-height: 48px only on mobile and set height 48px on anything else.
Since height and min-height are different properties, one doesn't overrides the other.
#Article_Header2 {
font: normal normal normal normal 16px / normal 'Roboto Condensed', sans-serif;
margin: 0px;
}
#media (min-width:768px) {
#Article_Header2 {
height: 48px;
}
}
#media (max-width:767px) {
#Article_Header2 {
min-height: 48px;
}
}

Media queries working only partially

Basically I'm playing around with these and I noticed that some of the properties do change as I want. Some (text-transform and font-size) have no effect (they work outside of the media query but not in). The p and #icon part work flawlessly, as well as color and font-family for .title, so I have zero clue as to why this happens.
Relevant code snippets:
#media only screen and (max-width: 1000px) {
p {
background-color: blue;
}
#icon {
display: none;
}
.title {
color: red;
text-transform: lowercase;
font-family: Arial;
font-size: 10px;
}
}
And for the regular screen size I have
.title {
text-transform: uppercase;
font-size: 35px;
font-weight: 300;
}
And in the HTML part
<h1 class="title" style="text-align: right; margin-bottom: 0px;">Jane Doette</h1>
For rules where the selectors are equally specific, the last one takes precedence.
Make the rule inside the media query more specific, for example changing .title to h1.title, or place the rules for regular screen size before the media query.
My guess is that your media query is placed before the non-media query style. If so, put your media query after: JS Fiddle - Media Query Last
.title {
text-transform: uppercase;
font-size: 35px;
font-weight: 300;
}
#media only screen and (max-width: 500px) {
p {
background-color: blue;
}
#icon {
display: none;
}
.title {
color: red;
text-transform: lowercase;
font-family: Arial;
font-size: 10px;
}
}
Otherwise, if the media query is first, the last styles in the style sheet will take precedent: JS Fiddle - Media Query First

CSS, Confused about #media with classes

I am trying to take my first forray into using "responsive" css, and I am working with this new #media ....... thing... and I am having a big of trouble understanding some of it. I have read up on it on multiple websites to form my code, and it isn't doing what I expected it to do, so I am getting more frustrated.
I basically have a place in text where, under normal circumstances, I want it to be font-size: 64px;, but if the screen gets very small (480px), I want it to be downsized to like 24px;. I added some other ridiculous properties to make sure I am actually getting the different result, but I am quite confused still.
So this was my approach...
#media (min-width: 480px) {
.name {
color: green;
font-family: "Comic Sans MS";
font-size: 24px;
}
}
.name {
font-size: 64px;
}
<span class="name">This is a really long name</span>
So I expected that when this runs, it will have the normal .name class, and if the resolution dips to 480px or thinner, it will go to the other one. Is this completely wrong? Because this is not what is happening for me.
The .name selector within the media query has the same specificity as the .name selector after the media query. Because of this, the later .name selector will take precedence.
Simply changing the order will fix the issue:
.name {
font-size: 64px;
}
#media (min-width: 480px) {
.name {
color: green;
font-family: "Comic Sans MS";
font-size: 24px;
}
}
If you'd like the styles within the media query to take effect when the screen is 480px or thinner, you should be using the max-width media query:
.name {
font-size: 64px;
}
#media (max-width: 480px) {
.name {
color: green;
font-family: "Comic Sans MS";
font-size: 24px;
}
}

HTML: Scalable Text

Hello I am making a website and i feel it is quite important that the text on the page is scalable for if the user has a smaller monitor or is using split screen.
I have the following HTML coding, that I believed would make it scale effectively but nothing happens?
HTML:
<p id="text">
View <a id="advertlinks" href="Prices.html">Prices</a> </br>Or <br><a id="advertlinks" href="Contact_Us.html">Book</a> A Lesson
</p>
CSS
#text
{
z-index:100;
position:absolute;
margin-top:-22%;
margin-left: 70%;
padding: 2%;
width: 22%;
height: 25%;
background-color: #f6da30;
opacity:0.6;
font-family: Impact, Charcoal, San-Serif;
font-size: 170%;
text-align: center;
-moz-border-radius: 30px;
border-radius: 30px;
}
Use CSS media queries:
#media all {
#text {
/* Default font size */
font-size: 12pt;
}
}
#media all and (max-width: 768px) {
#text {
/* Font size for smaller displays/screens */
font-size: 16pt;
}
}
Further reading: http://css-tricks.com/css-media-queries/
If you want the text to scale relative to the screen width, then your best bet is a responsive text jQuery plugin such as FlowType and FitText. If you want something light-weight, then you can use my Scalable Text jQuery plugin:
http://thdoan.github.io/scalable-text/
Sample usage:
<script>
$(document).ready(function() {
$('#text').scaleText();
}
</script>

Resources