中心的形式提交按钮HTML / CSS按钮、形式、中心、CSS

2023-09-11 07:42:35 作者:毁我又如何?

我有麻烦围绕我的HTML形式的CSS提交按钮。

I'm having troubles centering my html form submit buttons in css.

现在,我使用

    <input value="Search" title="Search" type="submit" id="btn_s"> 
    <input value="I'm Feeling Lucky" title="I'm Feeling Lucky" name="lucky" type="submit" id="btn_i">

这个CSS

with this css

    #btn_s{
    width:100px;
    margin-left:auto;
    margin-right:auto;
}

#btn_i {
    width:125px;
    margin-left:auto;
    margin-right:auto;
}

和它没有做任何事情,我知道我可能在做一些愚蠢的错误,任何人都可以帮我吗?

and it's not doing anything, I know i'm probably doing something stupid wrong, could anyone help me out?

感谢

推荐答案

http://jsfiddle.net/SebastianPataneMasuelli/rJxQC/

我只是缠绕其上一个div并使其居中对齐。那么你不需要的按钮任何CSS居中他们。

i just wrapped a div around them and made it align center. then you don't need any css on the buttons to center them.

<div class="buttonHolder">
  <input value="Search" title="Search" type="submit" id="btn_s"> 
  <input value="I'm Feeling Lucky" title="I'm Feeling Lucky" name="lucky" type="submit" id="btn_i">
</div>

.buttonHolder{ text-align: center; }