将两个表单元素内联放置

时间:2015-02-22 05:02:58

标签: html css forms

我目前有1个表单,里面有2个元素(电子邮件输入和提交按钮)。这个表格对我来说是这样的: Form on my computer 但我的一些同事似乎看起来像这样: form on my associates computers

我的相关HTML看起来像这样:

<header>
<div class="wrap nopad">
<h1>Share and Listen to Music.</h1>
<form>
<input type="email" placeholder="Email address to get started"><input type="submit" value="Get Started">
</form>
</div>
</header>

,相关的CSS看起来像这样:

body {
    background-color: #1B1B1E;
    color: #fff;
    margin:0;
    padding: 0;
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}
.wrap {
    width:685px;
    padding:0 15px;
    margin:0 auto;
    display: block;
}
.wrap.nopad {
    width:700px;
    padding: 0;
}
header {
    width:100%;
    padding:200px 0 100px;
    background-color: #2de6c0;
    display: block;
}
header .wrap h1 {
    color:#000;
    text-align: center;
    display: block;
    font-weight:bolder;
    text-transform: uppercase;
    font-size:45.4px;
    letter-spacing: 0px;
}
header .wrap h1 span {
    text-decoration: underline;
}
header form {
    padding:20px 0 0;
    width:660px;
    margin:0 auto;
}
input[type=email] {
    color:#000;
    padding:20px;
    display: inline-block;
    outline: 0;
    border: 0;
    width:470px;
    text-transform: uppercase;
    font-size:24px;
    font-weight: 500;
}
input[type=submit] {
    background-color: #000;
    color:#FFF;
    text-transform:uppercase;
    font-size:16px;
    padding:25px 20px;
    display: inline-block;
    font-weight:500;
    outline: 0;
    border: 0;
    cursor: pointer;
    float: right;
}

请指点我正确的方向,以便我可以修改我的代码,以便在所有浏览器中工作并内联。

谢谢!

1 个答案:

答案 0 :(得分:1)

Fiddle

 Reduce the padding of black submit button button.
 input[type=submit]
 {
   padding: 25px 16px;
 }

参见演示

Demo2

 It ll give you best design

 input email button --> Width:71.4%

 submit button  ---> Remove left and right padding and add width 22.54%