简体   繁体   English

CSS背景图像无响应

[英]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 基本上我们有以下图像,我很难制作流畅(响应)-logo(#learn-more)-banner图像(.banner-img) - 了解更多按钮(#learn-more)-image1和图像2

I have my demo here: http://jsfiddle.net/nLxjU/3/ 我在这里有我的演示: 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. 我真的被困在这里了。

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. 您可以使用具有绝对定位的不同div,并在其中包含具有百分位宽度和高度的图像,因此当屏幕大小更改时,div(以及其中的图像)也会调整大小。 Just place the div below everything with z-index and you're done. 只需使用z-index将div放在所有内容之下即可。

Email-clients, like Outlook (-Express), Mail (OSX) etc, all use different html-engines, and have a lot of restrictions. 电子邮件客户端,如Outlook(-Express),Mail(OSX)等,都使用不同的html引擎,并且有很多限制。 Especially Outlook seems to be using a limited IE6 based rendering engine. 特别是Outlook似乎使用有限的基于IE6的渲染引擎。 Background images and styling by css classes don't work, and forget about absolute or relative positioning. css类的背景图像和样式不起作用,忘记绝对或相对定位。

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/ . 访问http://www.emailology.org/查看标准指南(html / css)。

You can improve with the following, but as @Willem says you really need to change your approach if making an email template. 您可以通过以下方式进行改进 ,但正如@Willem所说,如果制作电子邮件模板,您确实需要更改方法。 Many email clients completely remove the head and strip out styles. 许多电子邮件客户端完全删除了head和剥离样式。 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/ 您可能会发现其中一些有用: 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. 您的.divider.banner-img元素设置为600px宽。 Set them as 100%. 将它们设置为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. .lpanel.rpanel图像的大小.lpanel为父级宽度的100%。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM