user2918348
user2918348

Reputation:

CSS Background Image Not responsive

Hi I'm trying to create a Responsive Email Template.

I can't make the background images responsive.

Here is a sample of the images code:

a#learn-more {  background-size: 100%; display: block; background: url('http://tophitechgadgets.com/wp-content/uploads/2013/11/learn-more.png')no-repeat; height: 68px; width: 600px; margin: 0 auto; }

Basically We have the following images that I am having a hard time making fluid (responsive) -logo (a#learn-more) -banner image (.banner-img) -learn more button (a#learn-more) -image1 and image2

I have my demo here: http://jsfiddle.net/nLxjU/3/

Hope you can edit the code to see what my issue why I cant make them responsive.

I'm really stuck here.

Upvotes: 1

Views: 1673

Answers (3)

Moob
Moob

Reputation: 16214

You can improve with the following, but as @Willem says you really need to change your approach if making an email template. Many email clients completely remove the head and strip out styles. Some support a limited set of inline styles for formatting and none for layout. In fact an old-school table layout with inline styles is generally the best way to go.

You might find some of this useful: http://www.campaignmonitor.com/guides/mobile/

As for making the best of what you've got so far:

  1. Your .divider and .banner-img elements were set to 600px wide. Set them as 100%.
  2. Don't have the banner as a background image.
  3. Size your .lpanel and .rpanel images as 100% of the parent's width.

Demo: http://jsfiddle.net/nLxjU/

Upvotes: 1

Willem
Willem

Reputation: 5404

Email-clients, like Outlook (-Express), Mail (OSX) etc, all use different html-engines, and have a lot of restrictions. Especially Outlook seems to be using a limited IE6 based rendering engine. Background images and styling by css classes don't work, and forget about absolute or relative positioning.

Make sure the template also looks good in these email-clients, unless you only aim at mobile email clients (they seem to support all of this).

Take a look at the standards guide (html/css) at http://www.emailology.org/.

Upvotes: 1

lights_on_me
lights_on_me

Reputation: 53

You can use a different div with absolute positioning, and containing the image inside it with percentile width and height, so when the screen size changes, the div (and the image inside it) resizes, too. Just place the div below everything with z-index and you're done.

Upvotes: 1

Related Questions