简体   繁体   English

如何在Zurb Foundation 6中将背景图像添加到HTML电子邮件中

[英]How to add background-image into HTML email in Zurb Foundation 6

I am trying to do HTML email with Zurb Foudation 6. After sending HTML email on mail clients there are don't show all background-images, but in web version everytning is ok. 我正在尝试使用Zurb Foudation 6发送HTML电子邮件。在邮件客户端上发送HTML电子邮件后,没有显示所有背景图像,但在网络版中,每个都可以。 How to correct add background-image? 如何正确添加背景图片? For exapmle I have this code: 为了exapmle我有这个代码:

<columns small="36" large="27" style="background-image: url('assets/img/BrownBG.png');>
    <spacer size="26"></spacer>
        <row>
            <columns small="18" large="18">
               <a>Link</a>
            </columns>
            <columns small="18" large="18">
               <a>Link</a>
            </columns>
        </row>
          <spacer size="20"></spacer>
        <row>
          <columns small="36" large="18">
              <p>Some paragraph</p>
          <spacer size="27"></spacer>
          </columns>
        </row>
</columns>

You need to place styles in app.scss (or included files), after that ZURB will be able to make correct inline style. 您需要在app.scss (或包含的文件)中放置样式,之后ZURB将能够生成正确的内联样式。 Do not write inline styles manual. 不要写内联样式手册。

Besides, you need setup babel to convert relative paths to abloluse like as in *.html templates. 此外,您需要设置babel将相对路径转换为abloluse,就像在* .html模板中一样。

.pipe($.if(!!awsURL, $.replace(/('|")(\/?assets\/img)/g, "$1" + awsURL)))

Example for aws: aws示例:

// Compile Sass into CSS
function sass() {
    var awsURL = !!CONFIG && !!CONFIG.aws && !!CONFIG.aws.url ? CONFIG.aws.url : false;
    return gulp.src('src/assets/scss/app.scss')
    .pipe($.if(!PRODUCTION, $.sourcemaps.init()))
    .pipe($.sass({
      includePaths: ['node_modules/foundation-emails/scss']
    }).on('error', $.sass.logError))
    .pipe($.if(PRODUCTION, $.uncss(
     {
        html: ['dist/**/*.html']
      })))
    .pipe($.if(!PRODUCTION, $.sourcemaps.write()))
    .pipe($.if(!!awsURL, $.replace(/('|")(\/?assets\/img)/g, "$1" + awsURL)))
    .pipe(gulp.dest('dist/css'));
}

and add creds pipe in task. 并在任务中添加creds管道。 It will look something like this: 它看起来像这样:

// Build emails, then send to EMAIL
gulp.task('mail',
  gulp.series(creds, 'build', aws, mail));

This is necessary to initialize the CONFIG var. 这是初始化CONFIG var所必需的。

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

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