【问题标题】:How can I center this submit button?我怎样才能使这个提交按钮居中?
【发布时间】:2015-02-05 16:34:39
【问题描述】:

我正在处理 this page 并尝试将“添加到购物车”(提交)按钮置于其父 div 中。我尝试了各种方法,但根本无法让它移动。

我试过form.cart { margin:auto; text-align:center; }.single_add_to_cart_button { margin:auto; text-align:center; },它们都没有任何作用。

提前感谢您的任何建议。

【问题讨论】:

标签: html css forms margin centering


【解决方案1】:

尝试使文本在父(表单)上居中对齐

form.cart {
    text-align: center;
}

【讨论】:

    【解决方案2】:

    正如 jmore009 所说,删除 float:left; 然后将 margin:0 auto 0 auto !important; 添加到 single_add_to_cart_button 的类中

    【讨论】:

      【解决方案3】:
      .single_add_to_cart_button { float:none; }
      

      【讨论】:

        【解决方案4】:

        只需从 button 中删除 float: left 并使用 single_add_to_cart_button

        【讨论】:

        • 谢谢。我从那个按钮中删除了float:left,但它似乎仍然没有居中...我错过了什么吗?
        • 你更新了那个页面吗?因为我仍然看到那里的浮动。它在.button 上。如果其他按钮需要此功能,您可以在 .single_add_to_cart_button 上添加 float: none 以覆盖它
        猜你喜欢
        • 1970-01-01
        • 2013-12-30
        • 2018-11-24
        • 1970-01-01
        • 2021-08-29
        • 2017-08-20
        • 2016-10-13
        • 1970-01-01
        • 2022-01-24
        相关资源
        最近更新 更多