【问题标题】:In a HTML-tag style"{...}{:active ... } doesn't work?在 HTML 标记样式中“{...}{:active ...} 不起作用?
【发布时间】:2013-10-05 13:08:17
【问题描述】:

我卡住了,因为我尝试了很多不同的组合,我不知道为什么这不起作用。

WordPress woocommerce 退房 从(提交)返回按钮 带有style="{} :active{}"的表单提交按钮标签

我没有头可以存储 css,只有一个带有表单的模板。 提交已经在主 style.css 中预先设置了样式。 我只想设计两个按钮“支付”和“返回”,而不是所有按钮。 我将完整的 css 放在按钮的 html 中,这是工作除了 :active 这不起作用

<table width="100%"><tr><td width="23%"><input type="submit" class="button alt" name="woocommerce_checkout_update_totals" id="place_order" value="<?php _e( 'back', Woocommerce_German_Market::get_textdomain() ) ?>" style="{position: relative;color: rgba(255,255,255,1);text-decoration: none;background-color: rgb(248, 1, 8);font-weight: bold;display: block;padding: 18px;-webkit-border-radius: 8px;-moz-border-radius: 8px;border-radius: 8px;-webkit-box-shadow: 0px 9px 0px rgb(179, 6, 1), 0px 9px 25px rgba(0,0,0,.7);-moz-box-shadow: 0px 9px 0px rgb(179, 6, 1), 0px 9px 25px rgba(0,0,0,.7);box-shadow: 0px 9px 0px rgb(179, 6, 1), 0px 9px 25px rgba(0,0,0,.7);margin: 2px 0px 25px 0px;text-align: center;-webkit-transition: all .1s ease;-moz-transition: all .1s ease;-ms-transition: all .1s ease;-o-transition: all .1s ease;transition: all .1s ease; font-size: 1.387em;} :active {-webkit-box-shadow: 0px 3px 0px rgb(179, 6, 1), 0px 3px 6px rgba(0,0,0,.9);-moz-box-shadow: 0px 3px 0px rgb(179, 6, 1), 0px 3px 6px rgba(0,0,0,.9);box-shadow:0px 3px 0px rgb(179, 6, 1), 0px 3px 6px rgba(0,0,0,.9);position: relative;top: 6px}" /></td>
<td width="77%"><div align="center">something maybe a button</div></td>
</tr>

【问题讨论】:

    标签: html css wordpress button


    【解决方案1】:

    style 属性中的语法不正确。

    使用style="property: value; ..." 而不是style="{}"

    因此,在您的情况下,它将是:

    <div style="width:50px; height:50px; background:blue;"></div>
    

    我建议避免所有内联样式,而是将逻辑移到样式表中:

    .active {
      width: 50px;
      height: 50px;
    }
    

    【讨论】:

    • 好的,但我只想设计一个按钮。 input 和 submit 已经设置了样式。我想特别为结帐模板中的结帐按钮覆盖这个。我没有 head-Tag 只有表单
    • @Marco-SiegfriedPenthin 然后你需要更具体的样式,看我的更新。我改用.button
    • 嘿乔希,非常感谢!在职的!! :-)
    • @Marco-SiegfriedPenthin 很高兴它有帮助。
    【解决方案2】:

    样式属性应该只包含 CSS 声明。它不应包含样式表中围绕它们的{}

    没有办法在样式属性中包含选择器,您需要为此使用常规样式表。

    【讨论】:

    • 好的,但是我如何实现 :active 来可视化按下的按钮?
    • 您使用样式表(通过&lt;link&gt;&lt;style&gt;)而不是样式属性。
    • 编辑.button { color: red; } .button:active { color: green; }中的按钮样式
    【解决方案3】:

    在标题中添加

    <style type='text/css'>
    input :active {
    -webkit-box-shadow: 0px 3px 0px rgb(179, 6, 1);
    //... what ever you have put for active 
    }
    </style>
    

    试试吧。

    【讨论】:

    • 好的,但我只想设计一个按钮。 input 和 submit 已经设置了样式。我想特别为结帐模板中的结帐按钮覆盖这个。我没有 head-Tag 只有表单
    • 使用 .class 名称我只是概括了它:)
    • 感谢 Anobik 的帮助
    猜你喜欢
    • 2013-06-02
    • 1970-01-01
    • 2019-11-23
    • 2018-03-02
    • 2014-04-22
    • 1970-01-01
    • 2015-08-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多