简体   繁体   English

如何将内联 CSS 添加到 Wordpress Visual Composer 中?

[英]How do I add inline CSS into the Wordpress Visual Composer?

I might be asking the wrong question (I'm not a coder), but I'm attempting to paste HTML and the inline stylesheet into the text-side (HTML-side) of the Wordpress Visual Composer to create an email layout, and the finished product of that is the entire stylesheet written out above the un-styled HTML layout, so I'm assuming inline stylesheets are not supported in this composer.我可能问错了问题(我不是编码员),但我试图将 HTML 和内联样式表粘贴到 Wordpress Visual Composer 的文本端(HTML 端)以创建 email 布局,并且最终产品是在未设置样式的 HTML 布局上方写出的整个样式表,因此我假设此作曲家不支持内联样式表。

Visual Composer 中的 HTML 视图 Visual Composer 中的视觉视图 损坏的电子邮件

Some back story for clarity, I'm using the plugin 'Download After Email' which only provides the standard Wordpress visual composer in order to create the email a user receives once they 'sign up'.为了清楚起见,我使用了一些背景故事,我正在使用插件“电子邮件后下载”,它只提供标准的 Wordpress 视觉作曲家,以便创建用户在“注册”后收到的 email。 This seemingly limits me to either jazzing up some text a little bit like I was using Microsoft Word (which isn't sufficient for a brand-focused business), or using raw standalone HTML, which isn't really sufficient for a properly formatted template.这似乎限制了我要么像使用 Microsoft Word 那样使一些文本更加生动(这对于以品牌为中心的业务来说是不够的),要么使用原始的独立 HTML,这对于格式正确的模板来说是不够的.

Are there any plugins which may assist in adding CSS styling here that will work once it's displayed externally to the website, ie in an email browser?是否有任何插件可以帮助在此处添加 CSS 样式,一旦它显示在网站外部(即在 email 浏览器中)就会起作用?

Judging by the image, you have a regular editor but not Visual Composer, and this is very good because this is the only right direction, You cannot create email templates using the constructor (Visual Composer) since creating an email template requires special old school knowledge (Tables. inline styles) and clean markup.从图像来看,你有一个普通的编辑器而不是 Visual Composer,这很好,因为这是唯一正确的方向,你不能使用构造函数(Visual Composer)创建 email 模板,因为创建 email 模板需要特殊的老派知识(表。内联样式)和干净的标记。 I advise you to take a ready-made template and change it to your own.我建议您使用现成的模板并将其更改为您自己的模板。

Example: https://colorlib.com/etc/email-template/3/index.html示例: https://colorlib.com/etc/email-template/3/index.html

What you need to know :你需要知道什么

  1. You need to use html tables您需要使用 html 表
  2. You need to use inline css您需要使用内联 css
  3. Use full src to display images ( https://yoursite.wp/.../demo.jpg ) the link you can get from the media post使用完整的 src 显示图像 ( https://yoursite.wp/.../demo.jpg ) 您可以从媒体帖子中获得的链接

Not recommended:不建议:

  1. To use css styles in the header if you are interested in Gmail App support: https://templates.mailchimp.com/resources/email-client-css-support/如果您对 Gmail 感兴趣,请在 header 中使用 css styles 应用支持: https://templates.mailchimp.com/resources/email-client-css-support/
  2. Custom fonts定制fonts
  3. Visual Composer and any other constructor Visual Composer 和任何其他构造函数

Addition:添加:

If you can use the shortcode system I recommend creating a mini plugin for you:如果您可以使用短代码系统,我建议为您创建一个迷你插件:

  • plugins/my-custom-emails [Root directory of new plugin] plugins/my-custom-emails [新插件的根目录]

  • plugins/my-custom-emails/my-custom-emails.php [Main php file of plugin] plugins/my-custom-emails/my-custom-emails.php [插件的主要 php 文件]

  • plugins/my-custom-emails/emails/ [Directory for for all your templates] plugins/my-custom-emails/emails/ [所有模板的目录]

  • plugins/my-custom-emails/emails/template1.html [First demo template] plugins/my-custom-emails/emails/template1.html [第一个演示模板]

my-custom-emails.php我的自定义电子邮件.php

<?php
/*
Plugin Name: My emails
Description: My custom emails
Version: 0.1.0
*/

define('MYCELS_DIR', plugin_dir_path(__FILE__));

add_shortcode( 'myemails', 'MYCELS_SHORTCODE' );
function MYCELS_SHORTCODE($attrs) {
    if(empty($attrs['id'])) {
        return 'ID required';
    }
    $ID = $attrs['id'];
    $PATH = MYCELS_DIR . 'emails/'.$ID.'.html';
    if(file_exists($PATH)) {
        return file_get_contents($PATH);
    } else {
        return 'File with '. $ID . ' ID not exists';
    }
}

template1.html模板1.html

<div>
    Template
</div>

And using:并使用:

[myemails id=template1]

Id = template name id = 模板名称

If you want something very customisable this plug-in would work, https://en-gb.wordpress.org/plugins/wp-html-mail/ It's very good and would recommend!如果你想要一些非常可定制的东西,这个插件可以工作, https://en-gb.wordpress.org/plugins/wp-html-mail/非常好,会推荐! With this you have full control over CSS and the HTML also comes with templates and has so much more control for what you need!有了它,您可以完全控制 CSS,而 HTML 也带有模板,并且可以根据您的需要进行更多控制!

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

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