CMS Development

HeatherThompson
Participant

How to use screen size display CSS inline?

SOLVE

Hi, I'm using drag and drop emails and have one tiny thing I need to tweak in an HTML module. Unfortunately, I'm not having luck finding the answer on StackOverflow.

I want an image to not display when the browser is below a certain width. 

If I could edit the style header, this is what I would put:

<style>@media (max-width: 600px) {
#fadeshow1 { display: none; }
}</style>


and then this in the body:
<img src="https://4733706.fs1.hubspotusercontent-na1.net/hubfs/4733706/top.png" style="height: 100%; width: 100%;" id="fadeshow1">

How do I convert this media query to inline CSS for this img?

For context, this is the full div:

<div style="background-image:url(https://4733706.fs1.hubspotusercontent-na1.net/hubfs/4733706/postcard2.png); height: 100%; background-size: contain; background-repeat: no-repeat;">

<img src="https://4733706.fs1.hubspotusercontent-na1.net/hubfs/4733706/top.png" id="fadeshow1">

<p style="margin: 70px 0 90px 0; font-size: 36px; font-weight: bold; color: #426D60;" align="center"><a href="https://www.indicotravels.com" style="text-decoration: none; color: #426D60;">Welcome!</a></p>

<img src="https://4733706.fs1.hubspotusercontent-na1.net/hubfs/4733706/top.png" id="fadeshow1">

</div>

 

0 Upvotes
1 Accepted solution
alyssamwilie
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

How to use screen size display CSS inline?

SOLVE

@HeatherThompson Media queries cannot be inlined and gmail wipes out any <style> blocks that aren't in the <head>. So, unfortantely, removing an element on mobile just isn't possible cross-client with drag-and-drop email. I've got my fingers crossed that someday HubSpot will allow adding styles to the <head>.

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.

View solution in original post

3 Replies 3
alyssamwilie
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

How to use screen size display CSS inline?

SOLVE

@HeatherThompson Media queries cannot be inlined and gmail wipes out any <style> blocks that aren't in the <head>. So, unfortantely, removing an element on mobile just isn't possible cross-client with drag-and-drop email. I've got my fingers crossed that someday HubSpot will allow adding styles to the <head>.

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
HeatherThompson
Participant

How to use screen size display CSS inline?

SOLVE

that's unfortunate but thank you for solving this for me!

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

How to use screen size display CSS inline?

SOLVE

Hi, @HeatherThompson 👋 Thanks for reaching out. Let's invite our community members to the conversation — hey @Anton @alyssamwilie, can you share any email-styling wisdom with @HeatherThompson?

 

Thank you! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot