HTML 按钮背景颜色属性不起作用

新手上路,请多包涵

在以下 页面 中:

我有一个灰色按钮(请参阅第一本书的部分,它是页面中唯一的灰色按钮)但它应该是蓝色的。我从邮件服务中剪切并粘贴代码(见下文)。属性:背景色:#47abd5;不起作用。为什么?

 <style>
    #mlb2-3734193 button.ml-subscribe-button {
        cursor: pointer;
        font-family: Open Sans!important;
        font-size: 24px !important;
        height: 60px;
        width: 250px;
        background-color: #47abd5;
        color: #ffffff!important;
        border: none;
        border-radius: 2px;
        padding: 0px 24px;
    }
</style>
<link href="https://fonts.googleapis.com/css?family=Open+Sans&   subset=latin,latin-ext" rel="stylesheet" type="text/css">
<form id="mlb2-3734193" action="//app.mailerlite.com/webforms/popup/z0d1n7" data-code="z0d1n7" data-id="243593" target="_blank">
    <div stylclass="button-preview">
        <button style="background-color: #47abd5;" type="submit" class="ml-subscribe-button">Iscriviti</button>
    </div>
</form>
<script type="text/javascript" src="//static.mailerlite.com/js/w/button.min.js?veb3acdd46bf692c067c6a9fe9fbc07d6"></script>

原文由 Salvatore D‘angelo 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 660
2 个回答

因为这个 css 被应用到你的按钮。

 a.button,
button,
html input[type="button"],
input[type="reset"],
input[type="submit"] {
  background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #dfdfdf), color-stop(1, #ffffff));
  background: -ms-linear-gradient(bottom, #dfdfdf, #ffffff);
  background: -moz-linear-gradient(center bottom, #dfdfdf 0%, #ffffff 100%);
  background: -o-linear-gradient(#ffffff, #dfdfdf);
}

我想有一个背景渐变会覆盖您的样式。正如@Turnip 建议将其更改为 background 而不是 background-colour 并且它会起作用

原文由 Raimonds 发布,翻译遵循 CC BY-SA 3.0 许可协议

删除 background-color 属性只需使用这样的背景:

 #mlb2-3734193 button.ml-subscribe-button {
       background: #47abd5;
        }

原文由 shyamm 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏