html - 如何使用两个也居中对齐的按钮将文本输入居中居中

标签 html css

这是html

<form id="ContactForm" action="">
  <div>
     <div class="wrapper">
        <div class="bg"><input class="input" type="text"></div>Name:
     </div>
     <div class="wrapper">
        <div class="bg"><input class="input" type="text"></div>Email:
     </div>
     <div class="wrapper">
        <div class="bg"><input class="input" type="text"></div>Phone:
     </div>
     <div class = "wrapper"> <a href="#" class="button" onclick="document.getElementById('ContactForm').submit()">Submit</a></div>
     <div class="wrapper"> <a href="#" class="button" onclick="document.getElementById('ContactForm').reset()">Generate code</a>
  </div>
</form>

CSS-

#ContactForm .button {
    margin: 0 auto;
    display:block;
    font-size:20px;
    font-weight:700;
    color:#fff;
    line-height:35px;
    width:90px;
    text-align:center;
    background:url(../images/button_form.gif) top repeat-x #308da2;
    border-radius:10px;
    -moz-border-radius:10px;
    -webkit-border-radius:10px;
    behavior:url(js/PIE.htc);
    position:relative;
    text-decoration:none
}

最佳答案

申请

text-align: center

到您表单的 CSS。

在这里http://jsfiddle.net/cpFZM/是基于您发布的代码的粗略示例。这将使所有内容居中对齐。如果您只想居中对齐某些元素,那么您只需将样式应用于包含它们的 divs

关于html - 如何使用两个也居中对齐的按钮将文本输入居中居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13837587/

相关文章:

html - 我如何水平和垂直居中页面上的图像,除非它太大而不适合?

css - PostCSS 中类似 Sass 的函数

javascript - 函数未定义javascript

javascript - 部分/内部链接 - 在点击上方留下边距

html - Bootstrap 嵌套行列高度

javascript - Jquery 循环在第一次加载时没有正确加载样式

javascript - 浏览器不想运行 .js

javascript - Chartjs 中的条形图未正确分组

html - img 悬停时的不透明度和颜色变化

javascript - Jvectormap 重叠区域,将区域置于顶部,z-index?