简体   繁体   English

用第二个样式表覆盖MailChimp样式表

[英]Override MailChimp stylesheet with second stylesheet

Goal: change background color of "Subscribe" button on MailChimp embedded sign-up form on company website page 目标:更改公司网站页面上MailChimp嵌入式注册表单上“订阅”按钮的背景颜色

Question: MailChimp gives the CSS hook "input.button" to style the Subscribe button. 问题:MailChimp提供了CSS钩子“ input.button”来设置“订阅”按钮的样式。 How do I use this CSS to override the styles already in place? 如何使用此CSS覆盖已经存在的样式?

The page I would like to edit: http://www.sieralearn.com/subscribe/ 我要编辑的页面: http : //www.sieralearn.com/subscribe/

Here is how the button is written in the HTML of the page: 这是在页面的HTML中编写按钮的方式:

<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>

As far as I can tell, I don't have access to the stylesheet used by MailChimp to generate the embed code ( http://cdn-images.mailchimp.com/embedcode/classic-081711.css ). 据我所知,我无权访问MailChimp用来生成嵌入代码的样式表( http://cdn-images.mailchimp.com/embedcode/classic-081711.css )。 Here is how the styles appear in the MailChimp stylesheet: 样式在MailChimp样式表中的显示方式如下:

#mc_embed_signup .button {clear:both; background-color: #aaa; border: 0 none; border-radius:4px; color: #FFFFFF; cursor: pointer; display: inline-block; font-size:15px; font-weight: bold; height: 32px; line-height: 32px; margin: 0 5px 10px 0; padding: 0 22px; text-align: center; text-decoration: none; vertical-align: top; white-space: nowrap; width: auto;}

Thank you for any and all assistance. 感谢您的协助。

Sorry, I'm too new to simply comment, but can't you simply copy the content of their stylesheet ( http://cdn-images.mailchimp.com/embedcode/classic-081711.css ) into a new stylesheet of your own, and reference your new one (in place of the old one) on your subscribe page? 抱歉,我太新了,不能简单地发表评论,但是您不能简单地将其样式表( http://cdn-images.mailchimp.com/embedcode/classic-081711.css )的内容复制到您的新样式表中拥有并在您的订阅页面上引用您的新书(代替旧书)? You can then change any of the design elements you wish without fouling up the ones you like. 然后,您可以更改所需的任何设计元素,而不会破坏所需的设计元素。

I implemented this on my blog one year ago and I was planning to write a tutorial, but I think this answer on SO will help people. 我在一年前在自己的博客上实现了此功能,并计划编写一个教程,但我认为SO上的答案将对人们有所帮助。 I have created a fiddle with the required HTML and CSS used to style the opt-in Mailchimp form. 我用必需的HTML和CSS创建了一个小提琴 ,用来为选择加入的Mailchimp表单设置样式。

The input.button can be styled completely as you wish, and here's the piece of code that changes the entire button, but you can wish to just change the background-color. input.button可以根据需要完全设置input.button样式,这是更改整个按钮的代码,但是您可能希望仅更改背景颜色。 If you want to have a look at a detailed form styling, refer to the fiddle attached as it has more niceties. 如果要查看详细的表单样式,请参阅附带的小提琴,因为它具有更多优点。

input.button {
    -moz-box-shadow:inset 0 1px 0 0 #bbdaf7;
    -webkit-box-shadow:inset 0 1px 0 0 #bbdaf7;
    box-shadow:inset 0 1px 0 0 #bbdaf7;
    background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #79bbff), color-stop(1, #378de5));
    background:-moz-linear-gradient(center top, #79bbff 5%, #378de5 100%);
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#79bbff', endColorstr='#378de5');
    background-color:#79bbff;
    -moz-border-radius:6px;
    -webkit-border-radius:6px;
    border-radius:6px;
    border:1px solid #84bbf3;
    display:inline-block;
    color:#fff;
    font-family:arial;
    font-size:16px;
    font-weight:700;
    padding:7px 32px;
    text-decoration:none;
    text-shadow:1px 1px 0 #528ecc;
}

Might wish to change the :hover with this piece of CSS. 可能希望通过这段CSS来更改:hover

input[class=button]:hover {
    background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #378de5), color-stop(1, #79bbff));
    background:-moz-linear-gradient(center top, #378de5 5%, #79bbff 100%);
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#378de5', endColorstr='#79bbff');
    background-color:#378de5
}

The HTML markup. HTML标记。

<div class="bu1">
     <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
 </div>

The final result. 最终结果。

在此处输入图片说明

Another option (not tested) is to do this in your custom style sheet or wherever: 另一个选择(未经测试)是在您的自定义样式表中或任何地方执行此操作:

#mc_embed_signup .button { background-color:lightcoral; }

The effect, as tested using Chrome Developer Tools is shown below. 使用Chrome Developer Tools测试的效果如下所示。

在此处输入图片说明

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

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